diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 1da30fbf62e..bc90d907c1f 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -6,6 +6,7 @@ Third party contributions are essential for making SDL great. However, we do hav Currently supported: * Ubuntu Linux 16.04 with GCC 5.4.x * Ubuntu Linux 18.04 with GCC 7.3.x +* Ubuntu Linux 20.04 with GCC 9.3.x * [C++11 standard](https://github.com/smartdevicelink/sdl_evolution/issues/132) ### Issues diff --git a/README.md b/README.md index 0046a0f6795..3bc77812685 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Pull Requests Welcome! Currently supported: * Ubuntu Linux 16.04 with GCC 5.4.x * Ubuntu Linux 18.04 with GCC 7.5.x +* Ubuntu Linux 20.04 with GCC 9.3.x * [C++11 standard](https://github.com/smartdevicelink/sdl_evolution/issues/132) ## Getting Started diff --git a/src/3rd_party-static/gmock-1.7.0/fused-src/gtest/gtest.h b/src/3rd_party-static/gmock-1.7.0/fused-src/gtest/gtest.h index 93359b61647..5f6ce8dbc7c 100644 --- a/src/3rd_party-static/gmock-1.7.0/fused-src/gtest/gtest.h +++ b/src/3rd_party-static/gmock-1.7.0/fused-src/gtest/gtest.h @@ -1823,16 +1823,16 @@ using ::std::tuple_size; # define GTEST_ATTRIBUTE_UNUSED_ #endif -// A macro to disallow operator= +// A macro to disallow copy operator= // This should be used in the private: declarations for a class. -#define GTEST_DISALLOW_ASSIGN_(type)\ - void operator=(type const &) +#define GTEST_DISALLOW_ASSIGN_(type) \ + type& operator=(type const &) = delete // A macro to disallow copy constructor and operator= // This should be used in the private: declarations for a class. -#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\ - type(type const &);\ - GTEST_DISALLOW_ASSIGN_(type) +#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type) \ + type(type const&) = delete; \ + type& operator=(type const&) = delete // Tell the compiler to warn about unused return values for functions declared // with this macro. The macro should be used on function declarations diff --git a/src/3rd_party-static/gmock-1.7.0/gtest/fused-src/gtest/gtest.h b/src/3rd_party-static/gmock-1.7.0/gtest/fused-src/gtest/gtest.h index 93359b61647..5f6ce8dbc7c 100644 --- a/src/3rd_party-static/gmock-1.7.0/gtest/fused-src/gtest/gtest.h +++ b/src/3rd_party-static/gmock-1.7.0/gtest/fused-src/gtest/gtest.h @@ -1823,16 +1823,16 @@ using ::std::tuple_size; # define GTEST_ATTRIBUTE_UNUSED_ #endif -// A macro to disallow operator= +// A macro to disallow copy operator= // This should be used in the private: declarations for a class. -#define GTEST_DISALLOW_ASSIGN_(type)\ - void operator=(type const &) +#define GTEST_DISALLOW_ASSIGN_(type) \ + type& operator=(type const &) = delete // A macro to disallow copy constructor and operator= // This should be used in the private: declarations for a class. -#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\ - type(type const &);\ - GTEST_DISALLOW_ASSIGN_(type) +#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type) \ + type(type const&) = delete; \ + type& operator=(type const&) = delete // Tell the compiler to warn about unused return values for functions declared // with this macro. The macro should be used on function declarations diff --git a/src/3rd_party-static/gmock-1.7.0/gtest/include/gtest/internal/gtest-port.h b/src/3rd_party-static/gmock-1.7.0/gtest/include/gtest/internal/gtest-port.h index 280935daca3..307a65d5927 100644 --- a/src/3rd_party-static/gmock-1.7.0/gtest/include/gtest/internal/gtest-port.h +++ b/src/3rd_party-static/gmock-1.7.0/gtest/include/gtest/internal/gtest-port.h @@ -716,16 +716,16 @@ using ::std::tuple_size; # define GTEST_ATTRIBUTE_UNUSED_ #endif -// A macro to disallow operator= +// A macro to disallow copy operator= // This should be used in the private: declarations for a class. -#define GTEST_DISALLOW_ASSIGN_(type)\ - void operator=(type const &) +#define GTEST_DISALLOW_ASSIGN_(type) \ + type& operator=(type const &) = delete // A macro to disallow copy constructor and operator= // This should be used in the private: declarations for a class. -#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\ - type(type const &);\ - GTEST_DISALLOW_ASSIGN_(type) +#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type) \ + type(type const&) = delete; \ + type& operator=(type const&) = delete // Tell the compiler to warn about unused return values for functions declared // with this macro. The macro should be used on function declarations diff --git a/src/3rd_party/CMakeLists.txt b/src/3rd_party/CMakeLists.txt index 0fdc0ba0137..26baeca3ebc 100644 --- a/src/3rd_party/CMakeLists.txt +++ b/src/3rd_party/CMakeLists.txt @@ -221,13 +221,14 @@ else() endif() set(BOOST_ROOT ${3RD_PARTY_INSTALL_PREFIX}) -find_package(Boost 1.66.0 COMPONENTS system thread date_time filesystem regex) -set(BOOST_LIB_SOURCE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/boost_src) -set(BOOST_LIBS_DIRECTORY ${3RD_PARTY_INSTALL_PREFIX}/lib) -set(BOOST_INCLUDE_DIR ${3RD_PARTY_INSTALL_PREFIX}/include PARENT_SCOPE) -SET_PROPERTY(GLOBAL PROPERTY GLOBAL_BOOST_LIBS ${BOOST_LIBS_DIRECTORY}) +set(Boost_NO_BOOST_CMAKE ON) +find_package(Boost 1.72.0 COMPONENTS system thread date_time filesystem regex) if (NOT ${Boost_FOUND}) - message(STATUS "Did not find boost. Downloading and installing boost 1.66") + set(BOOST_LIB_SOURCE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/boost_src) + set(BOOST_LIBS_DIRECTORY ${3RD_PARTY_INSTALL_PREFIX}/lib) + set(BOOST_INCLUDE_DIR ${3RD_PARTY_INSTALL_PREFIX}/include PARENT_SCOPE) + SET_PROPERTY(GLOBAL PROPERTY GLOBAL_BOOST_LIBS ${BOOST_LIBS_DIRECTORY}) + message(STATUS "Did not find boost. Downloading and installing boost 1.72") set(BOOST_INSTALL_COMMAND ./b2 install) if (${3RD_PARTY_INSTALL_PREFIX} MATCHES "/usr/local") set(BOOST_INSTALL_COMMAND sudo ./b2 install) @@ -235,18 +236,22 @@ if (NOT ${Boost_FOUND}) include(ExternalProject) ExternalProject_Add( Boost - URL https://mirror.bazel.build/dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.gz - URL_HASH SHA256=da3411ea45622579d419bfda66f45cd0f8c32a181d84adfa936f5688388995cf + URL https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.gz + URL_HASH SHA256=c66e88d5786f2ca4dbebb14e06b566fb642a1a6947ad8cc9091f9f445134143f DOWNLOAD_DIR ${BOOST_LIB_SOURCE_DIRECTORY} SOURCE_DIR ${BOOST_LIB_SOURCE_DIRECTORY} CONFIGURE_COMMAND ./bootstrap.sh --with-libraries=system,thread,date_time,filesystem,regex --prefix=${3RD_PARTY_INSTALL_PREFIX} BUILD_COMMAND ./b2 - INSTALL_COMMAND ${BOOST_INSTALL_COMMAND} --with-system --with-thread --with-date_time --with-filesystem --with-regex --prefix=${3RD_PARTY_INSTALL_PREFIX} > boost_install.log + INSTALL_COMMAND ${BOOST_INSTALL_COMMAND} --clean --prefix=${3RD_PARTY_INSTALL_PREFIX} && ${BOOST_INSTALL_COMMAND} --with-system --with-thread --with-date_time --with-filesystem --with-regex --prefix=${3RD_PARTY_INSTALL_PREFIX} > boost_install.log INSTALL_DIR ${3RD_PARTY_INSTALL_PREFIX} BUILD_IN_SOURCE true ) else() -add_custom_target(Boost) # empty target, Boost is already installed + message (STATUS "Boost installed in " ${Boost_LIBRARY_DIRS} ", " ${Boost_INCLUDE_DIRS}) + set(BOOST_LIBS_DIRECTORY ${Boost_LIBRARY_DIRS}) + set(BOOST_INCLUDE_DIR ${Boost_INCLUDE_DIRS} PARENT_SCOPE) + SET_PROPERTY(GLOBAL PROPERTY GLOBAL_BOOST_LIBS ${BOOST_LIBS_DIRECTORY}) + add_custom_target(Boost) # empty target, Boost is already installed endif() add_custom_target(install-3rd_party diff --git a/src/appMain/hmi_capabilities.json b/src/appMain/hmi_capabilities.json index 1e1c5aea791..8adb8da4b7a 100755 --- a/src/appMain/hmi_capabilities.json +++ b/src/appMain/hmi_capabilities.json @@ -105,55 +105,67 @@ "rows": 1 }, { - "name": "navigationText", + "name": "audioPassThruDisplayText1", "characterSet": "UTF_8", "width": 500, "rows": 1 }, { - "name": "audioPassThruDisplayText1", + "name": "audioPassThruDisplayText2", "characterSet": "UTF_8", "width": 500, "rows": 1 }, { - "name": "audioPassThruDisplayText2", + "name": "sliderHeader", "characterSet": "UTF_8", "width": 500, "rows": 1 }, { - "name": "sliderHeader", + "name": "sliderFooter", "characterSet": "UTF_8", "width": 500, "rows": 1 }, { - "name": "sliderFooter", + "name": "menuName", "characterSet": "UTF_8", "width": 500, "rows": 1 }, { - "name": "notificationText", + "name": "secondaryText", "characterSet": "UTF_8", "width": 500, "rows": 1 }, { - "name": "menuName", + "name": "tertiaryText", "characterSet": "UTF_8", "width": 500, "rows": 1 }, { - "name": "secondaryText", + "name": "menuCommandSecondaryText", "characterSet": "UTF_8", "width": 500, "rows": 1 }, { - "name": "tertiaryText", + "name": "menuCommandTertiaryText", + "characterSet": "UTF_8", + "width": 500, + "rows": 1 + }, + { + "name": "menuSubMenuSecondaryText", + "characterSet": "UTF_8", + "width": 500, + "rows": 1 + }, + { + "name": "menuSubMenuTertiaryText", "characterSet": "UTF_8", "width": 500, "rows": 1 @@ -212,6 +224,20 @@ "resolutionHeight": 35 } }, + { + "name": "menuCommandSecondaryImage", + "imageResolution": { + "resolutionWidth": 35, + "resolutionHeight": 35 + } + }, + { + "name": "menuSubMenuSecondaryImage", + "imageResolution": { + "resolutionWidth": 35, + "resolutionHeight": 35 + } + }, { "name": "appIcon", "imageResolution": { @@ -311,19 +337,106 @@ "dialNumberEnabled": true }, "videoStreamingCapability": { - "preferredResolution": { + "preferredResolution": { + "resolutionWidth": 800, + "resolutionHeight": 380 + }, + "maxBitrate": 20000, + "supportedFormats": [ + { + "protocol": "RAW", + "codec": "H264" + }, + { + "protocol": "RTP", + "codec": "H264" + }, + { + "protocol": "RTSP", + "codec": "Theora" + }, + { + "protocol": "RTMP", + "codec": "VP8" + }, + { + "protocol": "WEBM", + "codec": "VP9" + } + ], + "hapticSpatialDataSupported": true, + "diagonalScreenSize": 8, + "pixelPerInch": 96, + "scale": 1, + "preferredFPS": 15, + "additionalVideoStreamingCapabilities": [ + { + "preferredResolution": + { "resolutionWidth": 800, - "resolutionHeight": 350 + "resolutionHeight": 380 + }, + "hapticSpatialDataSupported": true, + "scale": 1, + "diagonalScreenSize": 8 }, - "maxBitrate": 10000, - "supportedFormats": [{ - "protocol": "RAW", - "codec": "H264" - }], - "hapticSpatialDataSupported": false, - "diagonalScreenSize": 8, - "pixelPerInch": 117, - "scale": 1 + { + "preferredResolution": + { + "resolutionWidth": 320, + "resolutionHeight": 200 + }, + "hapticSpatialDataSupported": false, + "diagonalScreenSize": 3 + }, + { + "preferredResolution": + { + "resolutionWidth": 480, + "resolutionHeight": 320 + }, + "hapticSpatialDataSupported": true, + "diagonalScreenSize": 5 + }, + { + "preferredResolution": + { + "resolutionWidth": 400, + "resolutionHeight": 380 + }, + "hapticSpatialDataSupported": true, + "diagonalScreenSize": 4 + }, + { + "preferredResolution": + { + "resolutionWidth": 800, + "resolutionHeight": 240 + }, + "hapticSpatialDataSupported": true, + "diagonalScreenSize": 4 + }, + { + "preferredResolution": + { + "resolutionWidth": 800, + "resolutionHeight": 380 + }, + "hapticSpatialDataSupported": true, + "scale": 1.5, + "diagonalScreenSize": 5 + }, + { + "preferredResolution": + { + "resolutionWidth": 800, + "resolutionHeight": 380 + }, + "hapticSpatialDataSupported": true, + "scale": 2, + "diagonalScreenSize": 4 + } + ] }, "driverDistractionCapability": { "menuLength": 10, diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index eff433fd1e3..50bbce6a97b 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -189,6 +189,13 @@ "NONE" ] }, + "OnAppCapabilityUpdated": { + "hmi_levels": [ + "BACKGROUND", + "FULL", + "LIMITED" + ] + }, "OnAppInterfaceUnregistered": { "hmi_levels": [ "BACKGROUND", @@ -545,6 +552,7 @@ "rpm", "steeringWheelAngle", "gearStatus", + "seatOccupancy", "handsOffSteering" ] }, @@ -564,6 +572,7 @@ "rpm", "steeringWheelAngle", "gearStatus", + "seatOccupancy", "handsOffSteering" ] }, @@ -583,6 +592,7 @@ "rpm", "steeringWheelAngle", "gearStatus", + "seatOccupancy", "handsOffSteering" ] }, @@ -602,6 +612,7 @@ "rpm", "steeringWheelAngle", "gearStatus", + "seatOccupancy", "handsOffSteering" ] } @@ -621,6 +632,7 @@ "deviceStatus", "engineOilLife", "engineTorque", + "climateData", "externalTemperature", "turnSignal", "fuelLevel", @@ -648,6 +660,7 @@ "deviceStatus", "engineOilLife", "engineTorque", + "climateData", "externalTemperature", "turnSignal", "fuelLevel", @@ -675,6 +688,7 @@ "deviceStatus", "engineOilLife", "engineTorque", + "climateData", "externalTemperature", "turnSignal", "fuelLevel", @@ -701,6 +715,7 @@ "deviceStatus", "engineOilLife", "engineTorque", + "climateData", "externalTemperature", "turnSignal", "fuelLevel", @@ -854,8 +869,7 @@ "hmi_levels": [ "FULL", "LIMITED", - "BACKGROUND", - "NONE" + "BACKGROUND" ] }, "UnpublishAppService": { @@ -1647,6 +1661,7 @@ "rpcs": { "CreateWindow": { "hmi_levels": [ + "NONE", "BACKGROUND", "FULL", "LIMITED" @@ -1654,6 +1669,7 @@ }, "DeleteWindow": { "hmi_levels": [ + "NONE", "BACKGROUND", "FULL", "LIMITED" @@ -3476,13 +3492,72 @@ "maxsize": 100, "since": "5.0" }, + { + "name": "climateData", + "params": [ + { + "name": "externalTemperature", + "key": "OEM_REF_EXT_TEMP", + "params": [ + { + "name": "unit", + "key": "OEM_REF_EXT_TEMP_UNIT", + "type": "TemperatureUnit", + "mandatory": true + }, + { + "name": "value", + "key": "OEM_REF_EXT_TEMP_VALUE", + "type": "Float", + "mandatory": true + } + ], + "type": "Struct", + "mandatory": false + }, + { + "name": "cabinTemperature", + "key": "OEM_REF_CABIN_TEMP", + "params": [ + { + "name": "unit", + "key": "OEM_REF_CABIN_TEMP_VALUE", + "type": "TemperatureUnit", + "mandatory": true + }, + { + "name": "value", + "key": "OEM_REF_CABIN_TEMP_VALUE", + "type": "Float", + "mandatory": true + } + ], + "type": "Struct", + "mandatory": false + }, + { + "name": "atmosphericPressure", + "key": "OEM_REF_ATMOSPHERIC_PRESSURE", + "type": "Float", + "minvalue": 0, + "maxvalue": 2000, + "mandatory": false + } + ], + "key": "OEM_REF_CLIMATE_DATA", + "type": "Struct", + "mandatory": false, + "since": "7.1" + }, { "name": "externalTemperature", "key": "OEM_REF_EXT_TEMP", "type": "Float", "mandatory": false, "minvalue": -40, - "maxvalue": 100 + "maxvalue": 100, + "deprecated": true, + "since": "7.1" }, { "name": "turnSignal", @@ -3859,25 +3934,63 @@ "name": "driverDoorAjar", "key": "OEM_REF_DR_DOOR_AJ", "type": "Boolean", - "mandatory": false + "mandatory": false, + "deprecated": true, + "since": "7.1" }, { "name": "passengerDoorAjar", "key": "OEM_REF_PAS_DOOR_AJ", "type": "Boolean", - "mandatory": false + "mandatory": false, + "deprecated": true, + "since": "7.1" }, { "name": "rearLeftDoorAjar", "key": "OEM_REF_REAR_LEFT_DOOR_AJ", "type": "Boolean", - "mandatory": false + "mandatory": false, + "deprecated": true, + "since": "7.1" }, { "name": "rearRightDoorAjar", "key": "OEM_REF_REAR_RIGHT_DOOR_AJ", "type": "Boolean", - "mandatory": false + "mandatory": false, + "deprecated": true, + "since": "7.1" + }, + { + "name": "doorStatuses", + "key": "OEM_REF_DOOR_STATUSES", + "array": true, + "type": "DoorStatus", + "mandatory": false, + "minsize": 0, + "maxsize": 100, + "since": "7.1" + }, + { + "name": "gateStatuses", + "key": "OEM_REF_GATE_STATUSES", + "array": true, + "type": "GateStatus", + "mandatory": false, + "minsize": 0, + "maxsize": 100, + "since": "7.1" + }, + { + "name": "roofStatuses", + "key": "OEM_REF_ROOF_STATUSES", + "array": true, + "type": "RoofStatus", + "mandatory": false, + "minsize": 0, + "maxsize": 100, + "since": "7.1" } ], "key": "OEM_REF_BODY_INF", @@ -4335,6 +4448,33 @@ "type": "Boolean", "mandatory": false, "since": "7.0" + }, + { + "name": "seatOccupancy", + "key": "OEM_REF_SEAT_OCCUP", + "params": [ + { + "name": "seatsOccupied", + "key": "OEM_REF_SEATS_OCCUP", + "type": "SeatStatus", + "array": true, + "minsize": 0, + "maxsize": 100, + "mandatory": false + }, + { + "name": "seatsBelted", + "key": "OEM_REF_SEATS_BELT", + "type": "SeatStatus", + "array": true, + "minsize": 0, + "maxsize": 100, + "mandatory": false + } + ], + "type": "Struct", + "mandatory": false, + "since": "7.1" } ] } diff --git a/src/appMain/smartDeviceLink.ini b/src/appMain/smartDeviceLink.ini index 0b27e6263a1..ed0e6725525 100644 --- a/src/appMain/smartDeviceLink.ini +++ b/src/appMain/smartDeviceLink.ini @@ -185,6 +185,9 @@ ForceUnprotectedService = Non ; The PTU will be triggered in case expiration date of certificate ; then certain hours amount UpdateBeforeHours = 24 +; Security level for openssl lib according to: +; https://www.openssl.org/docs/man1.1.0/man3/SSL_CTX_get_security_level.html +SecurityLevel = 1 [Policy] EnablePolicy = true diff --git a/src/components/application_manager/include/application_manager/app_service_manager.h b/src/components/application_manager/include/application_manager/app_service_manager.h index d26598c1e98..94606909c60 100644 --- a/src/components/application_manager/include/application_manager/app_service_manager.h +++ b/src/components/application_manager/include/application_manager/app_service_manager.h @@ -214,6 +214,13 @@ class AppServiceManager { virtual bool UpdateNavigationCapabilities( smart_objects::SmartObject& out_params); + /** + * @brief Retrieve the active service for handling waypoints if available + * @return The active NAVIGATION service if it handles waypoints, nullptr + * otherwise + */ + virtual AppService* FindWayPointsHandler(); + /** * @brief Get the RPCPassingHandler tied to this object * @return The RPCPassingHandler tied to this object diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index c08bb370824..bc966cd00cf 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -170,9 +170,14 @@ typedef std::map PerformChoice; typedef std::map PerformChoiceSetMap; /** - * @brief Defines id of SoftButton + * @brief Defines id of SoftButtons for specified WindowID */ -typedef std::set > SoftButtonID; +typedef std::pair > WindowSoftButtons; + +/** + * @brief Defines id of SoftButtons related to a specified WindowID + */ +typedef std::set SoftButtonIDs; /** * @brief Defines set of buttons subscription @@ -369,8 +374,8 @@ class DynamicApplicationData { /* * @brief Returns true if sub menu with such name already exist */ - virtual bool IsSubMenuNameAlreadyExist(const std::string& name, - const uint32_t parent_id) = 0; + DEPRECATED virtual bool IsSubMenuNameAlreadyExist( + const std::string& name, const uint32_t parent_id) = 0; /* * @brief Adds a interaction choice set to the application @@ -524,6 +529,7 @@ class Application : public virtual InitialApplicationData, * @brief The StreamingState enum defines current streaming state */ enum class StreamingState { kStopped, kStarted, kSuspended }; + enum ApplicationRegisterState { kRegistered = 0, kWaitingForRegistration }; Application() : is_greyed_out_(false) {} @@ -664,8 +670,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( @@ -961,10 +969,10 @@ class Application : public virtual InitialApplicationData, * Alert, Show, ScrollableMessage, ShowConstantTBT, AlertManeuver, * UpdateTurnList * @param cmd_id Unique command id from mobile API - * @param list of softbuttons were created by command. + * @param window_softbuttons list of softbuttons were created by command. */ - virtual void SubscribeToSoftButtons(int32_t cmd_id, - const SoftButtonID& softbuttons_id) = 0; + virtual void SubscribeToSoftButtons( + int32_t cmd_id, const WindowSoftButtons& window_softbuttons) = 0; /** * @brief Retreives window id on which given button is created 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 88668a25059..21e45b45151 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -142,7 +142,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(bool option); @@ -279,8 +280,8 @@ class ApplicationImpl : public virtual Application, bool AreCommandLimitsExceeded(mobile_apis::FunctionID::eType cmd_id, TLimitSource source); - virtual void SubscribeToSoftButtons(int32_t cmd_id, - const SoftButtonID& softbuttons_id); + virtual void SubscribeToSoftButtons( + int32_t cmd_id, const WindowSoftButtons& window_softbuttons); virtual bool IsSubscribedToSoftButton(const uint32_t softbutton_id); virtual void UnsubscribeFromSoftButtons(int32_t cmd_id); @@ -638,7 +639,7 @@ class ApplicationImpl : public virtual Application, /** * @brief Defines id of SoftButton which is related from name of command */ - typedef std::map CommandSoftButtonID; + typedef std::map CommandSoftButtonID; CommandNumberTimeLimit cmd_number_to_time_limits_; CommandSoftButtonID cmd_softbuttonid_; // Lock for command soft button id 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 bda1e5f49ec..9191a06c6bc 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 @@ -286,32 +286,22 @@ class ApplicationManagerImpl */ bool IsAppSubscribedForWayPoints(Application& app) const OVERRIDE; - void SaveWayPointsMessage( - smart_objects::SmartObjectSPtr way_points_message) OVERRIDE; + void SaveWayPointsMessage(smart_objects::SmartObjectSPtr way_points_message, + uint32_t app_id = 0) OVERRIDE; - /** - * @brief Subscribe Application for way points - * @param Application id - */ - void SubscribeAppForWayPoints(uint32_t app_id) OVERRIDE; + void SubscribeAppForWayPoints(uint32_t app_id, + bool response_from_hmi = true) OVERRIDE; - /** - * @brief Subscribe Application for way points - * @param Application pointer - */ - void SubscribeAppForWayPoints(ApplicationSharedPtr app) OVERRIDE; + void SubscribeAppForWayPoints(ApplicationSharedPtr app, + bool response_from_hmi = true) OVERRIDE; - /** - * @brief Unsubscribe Application for way points - * @param Application id - */ - void UnsubscribeAppFromWayPoints(uint32_t app_id) OVERRIDE; + void UnsubscribeAppFromWayPoints(uint32_t app_id, + bool response_from_hmi = true) OVERRIDE; - /** - * @brief Unsubscribe Application for way points - * @param Application pointer - */ - void UnsubscribeAppFromWayPoints(ApplicationSharedPtr app) OVERRIDE; + void UnsubscribeAppFromWayPoints(ApplicationSharedPtr app, + bool response_from_hmi = true) OVERRIDE; + + bool IsSubscribedToHMIWayPoints() const OVERRIDE; /** * @brief Is Any Application is subscribed for way points @@ -710,6 +700,9 @@ class ApplicationManagerImpl void RemoveDevice( const connection_handler::DeviceHandle& device_handle) OVERRIDE; + bool GetProtocolVehicleData( + connection_handler::ProtocolVehicleData& data) OVERRIDE; + /** * @brief OnDeviceSwitchingStart is invoked on device transport switching * start (e.g. from Bluetooth to USB) and creates waiting list of applications @@ -878,6 +871,10 @@ class ApplicationManagerImpl std::vector& rejected_params, const std::string& reason) OVERRIDE; + void OnAppStreaming(uint32_t app_id, + protocol_handler::ServiceType service_type, + bool state) OVERRIDE; + void OnAppStreaming(uint32_t app_id, protocol_handler::ServiceType service_type, const Application::StreamingState new_state) OVERRIDE; @@ -1154,6 +1151,8 @@ class ApplicationManagerImpl return is_stopping_; } + bool WaitForHmiIsReady() OVERRIDE; + /** * @brief ProcessReconnection handles reconnection flow for application on * transport switch @@ -1182,6 +1181,9 @@ class ApplicationManagerImpl bool IsSOStructValid(const hmi_apis::StructIdentifiers::eType struct_id, const smart_objects::SmartObject& display_capabilities); + virtual bool UnsubscribeAppFromSoftButtons( + const commands::MessageSharedPtr response) OVERRIDE; + /** * @brief Function returns supported SDL Protocol Version * @return protocol version depends on parameters from smartDeviceLink.ini. @@ -1191,7 +1193,15 @@ class ApplicationManagerImpl void ApplyFunctorForEachPlugin( std::function functor) OVERRIDE; + ns_smart_device_link_rpc::V1::v4_protocol_v1_2_no_extra& + mobile_v4_protocol_so_factory() OVERRIDE; + private: + /** + * @brief Sets is_stopping flag to true + */ + void InitiateStopping(); + /** * @brief Adds application to registered applications list and marks it as * registered @@ -1562,7 +1572,11 @@ class ApplicationManagerImpl */ std::set subscribed_way_points_apps_list_; - smart_objects::SmartObjectSPtr way_points_data_; + bool subscribed_to_hmi_way_points_; + + smart_objects::SmartObjectSPtr hmi_way_points_data_; + + std::map mobile_way_points_data_; /** * @brief Map contains applications which @@ -1610,12 +1624,14 @@ class ApplicationManagerImpl mobile_apis::SystemContext::eType system_context; }; - 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_; + ns_smart_device_link_rpc::V1::v4_protocol_v1_2_no_extra + mobile_v4_protocol_so_factory_; - static uint32_t mobile_corelation_id_; - static uint32_t corelation_id_; - static const uint32_t max_corelation_id_; + std::atomic mobile_correlation_id_; + std::atomic correlation_id_; + const uint32_t max_correlation_id_; std::unique_ptr hmi_capabilities_; // The reason of HU shutdown @@ -1643,6 +1659,9 @@ class ApplicationManagerImpl sync_primitives::Lock close_app_timer_pool_lock_; sync_primitives::Lock end_stream_timer_pool_lock_; + mutable sync_primitives::Lock wait_for_hmi_lock_; + sync_primitives::ConditionalVariable wait_for_hmi_condvar_; + StateControllerImpl state_ctrl_; std::unique_ptr app_launch_dto_; std::unique_ptr app_launch_ctrl_; 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 0bc98827c8d..f646c66ca15 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 @@ -81,6 +81,10 @@ class HMICapabilitiesImpl : public HMICapabilities { const std::string& ccpu_version() const OVERRIDE; + void set_hardware_version(const std::string& hardware_version) OVERRIDE; + + const std::string& hardware_version() const OVERRIDE; + bool attenuated_supported() const OVERRIDE; void set_attenuated_supported(const bool state) OVERRIDE; @@ -476,6 +480,7 @@ class HMICapabilitiesImpl : public HMICapabilities { bool is_rc_supported_; bool is_driver_distraction_supported_; std::string ccpu_version_; + std::string hardware_version_; smart_objects::SmartObjectSPtr navigation_capability_; smart_objects::SmartObjectSPtr phone_capability_; smart_objects::SmartObjectSPtr video_streaming_capability_; 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 7af9bacf275..9797442e34a 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -75,6 +75,7 @@ struct ResetGlobalPropertiesResult { bool menu_name; bool menu_icon; bool keyboard_properties; + bool user_location; bool vr_has_been_reset; ResetGlobalPropertiesResult() @@ -84,6 +85,7 @@ struct ResetGlobalPropertiesResult { , menu_name(false) , menu_icon(false) , keyboard_properties(false) + , user_location(false) , vr_has_been_reset(false) {} bool HasUIPropertiesReset() const { @@ -93,6 +95,10 @@ struct ResetGlobalPropertiesResult { bool HasTTSPropertiesReset() const { return timeout_prompt || help_prompt; } + + bool HasRCPropertiesReset() const { + return user_location; + } }; /** @@ -1062,6 +1068,18 @@ class MessageHelper { const ResetGlobalPropertiesResult& reset_result, const ApplicationSharedPtr application); + /** + * @brief CreateRCResetGlobalPropertiesRequest Creates request + * to reset global properties for RC + * @param reset_result struct containing result of global properties reset + * procedure + * @param application application for which properties are to be reset + * @return filled smart object with relevant request data + */ + static smart_objects::SmartObjectSPtr CreateRCResetGlobalPropertiesRequest( + const ResetGlobalPropertiesResult& reset_result, + const ApplicationSharedPtr application); + static smart_objects::SmartObject CreateAppServiceCapabilities( std::vector& all_services); 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 c123bcc764f..0a815b4c5b3 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 @@ -386,10 +386,14 @@ class PolicyHandler : public PolicyHandlerInterface, const std::string& wers_country_code, const std::string& language) OVERRIDE; + void OnHardwareVersionReceived(const std::string& hardware_version) OVERRIDE; + void SetPreloadedPtFlag(const bool is_preloaded) OVERRIDE; std::string GetCCPUVersionFromPT() const OVERRIDE; + std::string GetHardwareVersionFromPT() const OVERRIDE; + /** * @brief Sends GetVehicleData request in case when Vechicle info is ready. */ @@ -812,6 +816,9 @@ class PolicyHandler : public PolicyHandlerInterface, */ void LinkAppsToDevice(); + void SetHeartBeatTimeout(const std::string& policy_app_id, + const uint32_t app_id); + typedef std::vector Applications; /** diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h index a667dbf8e27..a4614d4f2c4 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_data_db.h @@ -352,6 +352,16 @@ class ResumptionDataDB : public ResumptionData { bool DeleteSavedSubscriptions(const std::string& policy_app_id, const std::string& device_id); + /** + * @brief Deletes userLocation from saved application + * @param policy_app_id - mobile application id + * @param device_id - contains id of device on which is running application + * @return true if data was deleted otherwise returns + * false + */ + bool DeleteUserLocation(const std::string& policy_app_id, + const std::string& device_id); + /** * @brief Deletes commands from saved application * @param policy_app_id - mobile application id @@ -441,6 +451,16 @@ class ResumptionDataDB : public ResumptionData { bool InsertChoiceSetData(const smart_objects::SmartObject& choicesets, int64_t application_primary_key) const; + /** + * @brief Saves user location data to DB + * @param user_location contains data for saving + * @param application_primary_key - primary key from DB table application + * @return true if data was saved successfully otherwise returns + * false + */ + bool InsertUserLocationData(const smart_objects::SmartObject& user_location, + int64_t application_primary_key) const; + /** * @brief Saves globalProperties data to DB * @param global_properties contains data for saving @@ -689,6 +709,18 @@ class ResumptionDataDB : public ResumptionData { const std::string& device_id, smart_objects::SmartObject& saved_app) const; + /** + * @brief Selects data from applicationUserLocation table + * @param policy_app_id contains mobile application id of application + * @param device_id contains id of device on which is running application + * @param saved_app contains userLocation + * @return true if query has been executed successfully otherwise returns + * false + */ + bool SelectUserLocationData(const std::string& policy_app_id, + const std::string& device_id, + smart_objects::SmartObject& saved_app) const; + /** * @brief Selects choice set data from DB * @param policy_app_id contains mobile application id of application diff --git a/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h b/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h index eee7650697d..c62d1154484 100644 --- a/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h +++ b/src/components/application_manager/include/application_manager/resumption/resumption_sql_queries.h @@ -66,6 +66,7 @@ extern const std::string kDeleteApplicationFilesArray; extern const std::string kDeleteSubMenu; extern const std::string kDeleteApplicationSubMenuArray; extern const std::string kDeleteApplicationSubscriptionsArray; +extern const std::string kDeleteApplicationUserLocation; extern const std::string kDeleteImageFromCommands; extern const std::string kDeleteVrCommands; extern const std::string kDeleteCommands; @@ -97,6 +98,7 @@ extern const std::string kInsertToCommand; extern const std::string kInsertApplicationCommandArray; extern const std::string kInsertVrCommand; extern const std::string kInsertSubscriptions; +extern const std::string kInsertUserLocation; extern const std::string kInsertChoice; extern const std::string kInsertApplicationChoiceSet; extern const std::string kInsertChoiceArray; @@ -117,6 +119,8 @@ extern const std::string kSelectCountCommands; extern const std::string kSelectCommands; extern const std::string kSelectCountSubscriptions; extern const std::string kSelectSubscriptions; +extern const std::string kSelectCountUserLocation; +extern const std::string kSelectUserLocation; extern const std::string kSelectCountChoiceSet; extern const std::string kSelectChoiceSets; extern const std::string kSelectImage; 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 ab140dbd8a6..dd4fb3d3095 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 @@ -181,6 +181,7 @@ class RPCHandlerImpl : public RPCHandler, const bool validate_params = true); std::shared_ptr ConvertRawMsgToMessage( const ::protocol_handler::RawMessagePtr message); + hmi_apis::HMI_API& hmi_so_factory(); mobile_apis::MOBILE_API& mobile_so_factory(); 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 c96c9ebe697..5572dfd55d5 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 @@ -171,6 +171,9 @@ extern const char* minutes; extern const char* seconds; extern const char* update_mode; extern const char* audioStreamingIndicator; +extern const char* seek_time; +extern const char* forward_seek_indicator; +extern const char* back_seek_indicator; extern const char* trigger_source; extern const char* hmi_level; extern const char* activate_app_hmi_level; @@ -227,6 +230,8 @@ extern const char* policy_type; extern const char* property; extern const char* displays; extern const char* seat_location; +extern const char* app_capability; +extern const char* app_capability_type; // PutFile extern const char* sync_file_name; @@ -296,6 +301,7 @@ extern const char* fuel_level_state; extern const char* instant_fuel_consumption; extern const char* fuel_range; extern const char* cloud_app_vehicle_id; +extern const char* climate_data; extern const char* external_temp; extern const char* turn_signal; extern const char* vin; @@ -336,11 +342,13 @@ extern const char* video_streaming; extern const char* remote_control; extern const char* sdl_version; extern const char* system_software_version; +extern const char* system_hardware_version; extern const char* priority; extern const char* engine_oil_life; extern const char* oem_custom_data_type; extern const char* window_status; extern const char* hands_off_steering; +extern const char* seat_occupancy; // app services extern const char* app_service_manifest; @@ -480,10 +488,12 @@ 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 additional_video_streaming_capabilities; extern const char* const haptic_rect_data; extern const char* const rect; extern const char* const x; extern const char* const y; +extern const char* const preferred_fps; } // namespace strings namespace hmi_interface { @@ -584,6 +594,8 @@ extern const char* method_name; extern const char* keyboard_layout; extern const char* limited_character_list; extern const char* auto_complete_list; +extern const char* mask_input_characters; +extern const char* custom_keys; extern const char* file; extern const char* file_name; extern const char* retry; @@ -621,6 +633,9 @@ extern const char* image_capabilities; extern const char* display_type; extern const char* display_name; extern const char* text_fields; +extern const char* keyboard_capabilities; +extern const char* supported_keyboards; +extern const char* num_configurable_keys; extern const char* media_clock_formats; extern const char* graphic_supported; extern const char* image_fields; 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 8d3a3d796ec..c3b0a7d4a55 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 @@ -284,10 +284,8 @@ void GetInteriorVehicleDataRequest::on_event( [message_params::kModuleData][data_mapping(module_type)]; interior_data_cache_.Add(module, module_data); } - } else { - hmi_response[app_mngr::strings::msg_params].erase( - message_params::kIsSubscribed); } + std::string response_info; GetInfo(hmi_response, response_info); SetResourceState(ModuleType(), ResourceState::FREE); @@ -295,7 +293,7 @@ void GetInteriorVehicleDataRequest::on_event( SendResponse(result, result_code, response_info.c_str(), - &hmi_response[app_mngr::strings::msg_params]); + result ? &hmi_response[app_mngr::strings::msg_params] : nullptr); } GetInteriorVehicleDataRequest::~GetInteriorVehicleDataRequest() {} 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 3bfad3095b7..b6233503885 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 @@ -88,7 +88,8 @@ void RCAppExtension::UnsubscribeFromInteriorVehicleData( void RCAppExtension::UnsubscribeFromInteriorVehicleDataOfType( const std::string& module_type) { bool unsubscribed = false; - for (auto& item : subscribed_interior_vehicle_data_) { + auto subscribed_ivi = subscribed_interior_vehicle_data_; + for (auto& item : subscribed_ivi) { if (module_type == item.first) { subscribed_interior_vehicle_data_.erase(item); unsubscribed = true; @@ -198,15 +199,13 @@ void RCAppExtension::RevertResumption( const auto module_subscriptions = ConvertSmartObjectToModuleCollection(resumption_data); - for (auto& module : module_subscriptions) { - SDL_LOG_TRACE("Requested to unsubscribe module_type " - << module.first << "module_id: " << module.second); - } std::set to_be_unsubscribed; const auto app_id = application_.app_id(); auto no_apps_subscribed = [app_id, this](const rc_rpc_plugin::ModuleUid& module) { + SDL_LOG_TRACE("Requested to unsubscribe module_type " + << module.first << "module_id: " << module.second); if (plugin_.IsOtherAppsSubscribed(module, app_id)) { SDL_LOG_DEBUG("Some other app except " << app_id << " is already subscribed to " 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 20f9c279123..fdfa3ea03ac 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 @@ -734,6 +734,8 @@ TEST_F(GetInteriorVehicleDataRequestTest, available_hd_chanels[1] = chanel2_index; available_hd_chanels[2] = chanel3_index; + msg_params[message_params::kModuleData][message_params::kModuleId] = + kModuleId; msg_params[message_params::kModuleData][message_params::kRadioControlData] [message_params::kAvailableHdChannels] = available_hd_chanels; @@ -792,6 +794,8 @@ TEST_F(GetInteriorVehicleDataRequestTest, smart_objects::SmartObject(smart_objects::SmartType_Boolean); climate_control_data = true; + msg_params[message_params::kModuleData][message_params::kModuleId] = + kModuleId; msg_params[message_params::kModuleData][message_params::kClimateControlData] [message_params::kClimateEnableAvailable] = climate_control_data; 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 a03b34d7422..67a178893c6 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 @@ -28,7 +28,10 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -include_directories(include) +include_directories( + include + ${CMAKE_CURRENT_SOURCE_DIR}/include/sdl_rpc_plugin +) set (COMMANDS_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/commands diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_on_app_capability_updated_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_on_app_capability_updated_notification.h new file mode 100644 index 00000000000..f4883cecaf8 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/hmi/bc_on_app_capability_updated_notification.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2020, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BC_ON_APP_CAPABILITY_UPDATED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BC_ON_APP_CAPABILITY_UPDATED_NOTIFICATION_H_ + +#include "application_manager/commands/notification_to_hmi.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class BCOnAppCapabilityUpdatedNotification + : public app_mngr::commands::NotificationToHMI { + public: + BCOnAppCapabilityUpdatedNotification( + 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); + + ~BCOnAppCapabilityUpdatedNotification() OVERRIDE; + + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(BCOnAppCapabilityUpdatedNotification); +}; + +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_HMI_BC_ON_APP_CAPABILITY_UPDATED_NOTIFICATION_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 2d3c40c3f37..5254d641def 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 @@ -45,6 +45,7 @@ struct SystemInfo { std::string ccpu_version; std::string wers_country_code; std::string language; + std::string hardware_version; }; /** 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 17d4eb483f0..d2bda320a30 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 @@ -72,6 +72,8 @@ class NaviIsReadyRequest : public app_mngr::commands::RequestToHMI, **/ void on_event(const app_mngr::event_engine::Event& event) OVERRIDE; + void onTimeOut() OVERRIDE; + private: DISALLOW_COPY_AND_ASSIGN(NaviIsReadyRequest); }; 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 index 39b5c3aee39..41b5846a463 100644 --- 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 @@ -87,6 +87,18 @@ class OnBCSystemCapabilityUpdatedNotificationFromHMI ProcessSystemDisplayCapabilitiesResult ProcessSystemDisplayCapabilities( const smart_objects::SmartObject& display_capabilities); + /** + * @brief ProcessVideoStreamingCapability processes provided video + * streaming capabilities according to its structure + * @param system_capability capabilities to process + * @return true if video streaming capabilities have been processed + * properly, otherwise returns false + */ + bool ProcessVideoStreamingCapability( + const smart_objects::SmartObject& system_capability); + + void RemoveAppIdFromNotification(); + DISALLOW_COPY_AND_ASSIGN(OnBCSystemCapabilityUpdatedNotificationFromHMI); }; 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 db4f265a9fd..ed89bc73ec1 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 @@ -46,8 +46,7 @@ namespace commands { /** * @brief UpdateDeviceListRequest command class **/ -class UpdateDeviceListRequest : public app_mngr::commands::RequestToHMI, - public app_mngr::event_engine::EventObserver { +class UpdateDeviceListRequest : public app_mngr::commands::RequestToHMI { public: /** * @brief UpdateDeviceListRequest class constructor @@ -70,23 +69,7 @@ class UpdateDeviceListRequest : public app_mngr::commands::RequestToHMI, **/ virtual void Run(); - /** - * @brief Interface method that is called whenever new event received - * Need to observe OnHMIReady event, to send UpdateDeviceListRequest - * when HMI will be ready - * @param event The received event - */ - virtual void on_event(const app_mngr::event_engine::Event& event); - - /** - * @brief Need to stop execution StopMethod if HMI did not started - */ - virtual bool CleanUp(); - private: - sync_primitives::Lock wait_hmi_lock; - sync_primitives::ConditionalVariable termination_condition_; - DISALLOW_COPY_AND_ASSIGN(UpdateDeviceListRequest); }; 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 8cac0d686d9..6ccd57947c7 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 @@ -90,16 +90,6 @@ class AddCommandRequest : public app_mngr::commands::CommandRequestImpl { bool Init() FINAL; private: - /* - * @brief Check if command name doesn't exist in application - * Please see SDLAQ-CRS-407 for more information - * - * @param app Mobile application - * - * @return TRUE on success, otherwise FALSE - */ - bool CheckCommandName(app_mngr::ApplicationConstSharedPtr app); - /* * @brief Check if command VR synonyms doesn't exist in application commands * Please see SDLAQ-CRS-407 for more information 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 a1bc8663478..aba2ce3be50 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 @@ -161,56 +161,6 @@ class CreateInteractionChoiceSetRequest mobile_apis::Result::eType CheckChoiceSet( 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 - */ - struct CoincidencePredicateChoiceID { - CoincidencePredicateChoiceID(const uint32_t newItem) : newItem_(newItem) {} - - bool operator()(smart_objects::SmartObject obj) { - return obj[app_mngr::strings::choice_id].asUInt() == newItem_; - } - - const uint32_t newItem_; - }; - - /* - * @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) {} - - bool operator()(smart_objects::SmartObject obj) { - return obj[app_mngr::strings::menu_name].asString() == newItem_; - } - - const std::string& newItem_; - }; - - /* - * @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) {} - - bool operator()(smart_objects::SmartObject obj) { - return compareStr(obj, newItem_); - } - - const smart_objects::SmartObject& newItem_; - }; - /* * @brief Checks if incoming choice set doesn't has similar VR synonyms. * diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_app_capability_updated_notification.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_app_capability_updated_notification.h new file mode 100644 index 00000000000..64e16f57bef --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_app_capability_updated_notification.h @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2020, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_CAPABILITY_UPDATED_NOTIFICATION_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_CAPABILITY_UPDATED_NOTIFICATION_H_ + +#include "application_manager/commands/command_notification_from_mobile_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace commands { +namespace mobile { + +namespace app_mngr = application_manager; +class OnAppCapabilityUpdatedNotification + : public app_mngr::commands::CommandNotificationFromMobileImpl { + public: + /** + * @brief OnAppPermissionChangedNotification class constructor + * @param message Incoming SmartObject message + * @param application_manager Reference to the instance of the Application + *Manager + * @param rpc_service Reference to the instance of the RPCService + * @param hmi_capabilities Reference to the instance of the HMICapabilities + * @param policy_handle Reference to the instance of the PolicyHandler + **/ + OnAppCapabilityUpdatedNotification( + 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 OnAppPermissionChangedNotification class destructor + **/ + ~OnAppCapabilityUpdatedNotification() OVERRIDE; + + /** + * @brief Execute command + **/ + void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(OnAppCapabilityUpdatedNotification); +}; + +} // namespace mobile +} // namespace commands +} // namespace sdl_rpc_plugin + +#endif // SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_APP_CAPABILITY_UPDATED_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_from_mobile.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification_from_mobile.h new file mode 100644 index 00000000000..2ad9a4c0afb --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/include/sdl_rpc_plugin/commands/mobile/on_way_point_change_notification_from_mobile.h @@ -0,0 +1,75 @@ +/* + * 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_ON_WAY_POINT_CHANGE_NOTIFICATION_FROM_MOBILE_H_ +#define SRC_COMPONENTS_APPLICATION_MANAGER_RPC_PLUGINS_SDL_RPC_PLUGIN_INCLUDE_SDL_RPC_PLUGIN_COMMANDS_MOBILE_ON_WAY_POINT_CHANGE_NOTIFICATION_FROM_MOBILE_H_ + +#include "application_manager/commands/command_notification_from_mobile_impl.h" +#include "utils/macro.h" + +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; + +namespace commands { + +class OnWayPointChangeNotificationFromMobile + : public app_mngr::commands::CommandNotificationFromMobileImpl { + public: + /** + * @brief OnWayPointChangeNotificationFromMobile class constructor + * + * @param message Incoming SmartObject message + **/ + OnWayPointChangeNotificationFromMobile( + 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 OnWayPointChangeNotificationFromMobile class destructor + **/ + virtual ~OnWayPointChangeNotificationFromMobile(); + + /** + * @brief Execute command + **/ + virtual void Run() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(OnWayPointChangeNotificationFromMobile); +}; + +} // namespace commands +} // 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_FROM_MOBILE_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 52a0ad4dc1d..88182a0b8e6 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 @@ -128,15 +128,13 @@ class PerformInteractionRequest * @return true if send response to mobile application otherwise * return false. */ - bool ProcessVRResponse(const smart_objects::SmartObject& message, - smart_objects::SmartObject& msg_params); + bool ProcessVRResponse(const smart_objects::SmartObject& message); /** * @brief Sends PerformInteraction response to mobile side * @param message which should send to mobile side */ - void ProcessUIResponse(const smart_objects::SmartObject& message, - smart_objects::SmartObject& msg_params); + void ProcessUIResponse(const smart_objects::SmartObject& message); /* * @brief Sends UI PerformInteraction request to HMI @@ -163,16 +161,6 @@ class PerformInteractionRequest */ void SendUIShowVRHelpRequest(app_mngr::ApplicationSharedPtr const app); - /* - * @brief Checks if incoming choice set doesn't has similar menu names. - * - * @param app_id Application ID - * - * return Return TRUE if there are no similar menu names in choice set, - * otherwise FALSE - */ - bool CheckChoiceSetMenuNames(app_mngr::ApplicationSharedPtr const app); - /* * @brief Checks if incoming choice set doesn't has similar VR synonyms. * @@ -279,6 +267,7 @@ class PerformInteractionRequest mobile_apis::InteractionMode::eType interaction_mode_; std::int32_t ui_choice_id_received_; std::int32_t vr_choice_id_received_; + std::string ui_text_entry_received_; bool ui_response_received_; bool vr_response_received_; 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 fae8f5eeb74..ae52caf0f70 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 @@ -260,12 +260,6 @@ class RegisterAppInterfaceRequest mobile_apis::Result::eType ProcessingAppHMITypesInMessage( const smart_objects::SmartObject& message); - /** - * @brief WaitForHMIIsReady blocking function. Waits for HMI be ready for - * requests processing - */ - void WaitForHMIIsReady(); - /** * @brief FillApplicationParams set app application attributes from the RAI * request 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 190cb074593..fbf3056e58a 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 @@ -203,7 +203,30 @@ class SetGlobalPropertiesRequest */ bool IsWhiteSpaceExist(); - /* + /** + * @brief helps to determine layout of interest. Returns keyboard layout, + * mentioned in current request. If not, returns saved keyboard layout for + * current app. If such layout wasn't saved, returns default keyboard layout + * (QWERTY) + * @return KeyboardLayout enum value + */ + hmi_apis::Common_KeyboardLayout::eType GetKeyboardLayout() const; + + /** + * @brief Returns allowed number of configurable keys for certain layout + * @return allowed number of configurable keys, if provided, and zero + * otherwise + */ + uint32_t GetAllowedNumberOfConfigurableKeys() const; + + /** + * @brief Checks provided custom keys against capabilities. + * @return true if the specified keyboard layout supports the number of + * custom keys provided. + */ + bool ValidateCustomKeys() const; + + /** * @brief Prepare result code and result for sending to mobile application * @param result_code contains result code for sending to mobile application * @param info contains info for sending to mobile applicaion 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 adced13d73b..3023bf4fec1 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 @@ -74,7 +74,7 @@ class SetMediaClockRequest : public app_mngr::commands::CommandRequestImpl { void on_event(const app_mngr::event_engine::Event& event); private: - bool isDataValid(); + bool isDataValid(std::string& info); DISALLOW_COPY_AND_ASSIGN(SetMediaClockRequest); }; 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 8b88a1c884a..69154d76692 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 @@ -76,6 +76,8 @@ class SubscribeWayPointsRequest */ bool Init() FINAL; + void onTimeOut() FINAL; + private: DISALLOW_COPY_AND_ASSIGN(SubscribeWayPointsRequest); }; 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 e83e9b7509d..c4357d75292 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 @@ -75,6 +75,8 @@ class UnsubscribeWayPointsRequest */ bool Init() FINAL; + void onTimeOut() FINAL; + private: DISALLOW_COPY_AND_ASSIGN(UnsubscribeWayPointsRequest); }; diff --git a/src/components/include/test/protocol_handler/mock_telemetry_observer.h b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_on_app_capability_updated_notification.cc similarity index 58% rename from src/components/include/test/protocol_handler/mock_telemetry_observer.h rename to src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_on_app_capability_updated_notification.cc index 82c42775fa3..a5f21371365 100644 --- a/src/components/include/test/protocol_handler/mock_telemetry_observer.h +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/bc_on_app_capability_updated_notification.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Ford Motor Company + * Copyright (c) 2020, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,26 +30,34 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef SRC_COMPONENTS_INCLUDE_TEST_PROTOCOL_HANDLER_MOCK_TELEMETRY_OBSERVER_H_ -#define SRC_COMPONENTS_INCLUDE_TEST_PROTOCOL_HANDLER_MOCK_TELEMETRY_OBSERVER_H_ +#include "sdl_rpc_plugin/commands/hmi/bc_on_app_capability_updated_notification.h" -#include "gmock/gmock.h" +namespace sdl_rpc_plugin { +namespace app_mngr = application_manager; -#include "protocol_handler/telemetry_observer.h" +namespace commands { -namespace test { -namespace components { -namespace protocol_handler_test { +SDL_CREATE_LOG_VARIABLE("Commands") -class MockPHTelemetryObserver : public PHTelemetryObserver { - public: - MOCK_METHOD2(StartMessageProcess, - void(uint32_t message_id, - const date_time::TimeDuration& start_time)); - MOCK_METHOD1(EndMessageProcess, void(std::shared_ptr m)); -}; +BCOnAppCapabilityUpdatedNotification::BCOnAppCapabilityUpdatedNotification( + const application_manager::commands::MessageSharedPtr& message, + application_manager::ApplicationManager& application_manager, + application_manager::rpc_service::RPCService& rpc_service, + application_manager::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : NotificationToHMI(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} -} // namespace protocol_handler_test -} // namespace components -} // namespace test -#endif // SRC_COMPONENTS_INCLUDE_TEST_PROTOCOL_HANDLER_MOCK_TELEMETRY_OBSERVER_H_ +BCOnAppCapabilityUpdatedNotification::~BCOnAppCapabilityUpdatedNotification() {} + +void BCOnAppCapabilityUpdatedNotification::Run() { + SDL_LOG_AUTO_TRACE(); + + SendNotification(); +} + +} // namespace commands +} // 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 20250af222c..722bfc50975 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 @@ -60,11 +60,10 @@ void ButtonGetCapabilitiesResponse::Run() { static_cast( (*message_)[strings::params][hmi_response::code].asInt()); - hmi_capabilities_.UpdateRequestsRequiredForCapabilities( - hmi_apis::FunctionID::Buttons_GetCapabilities); - if (hmi_apis::Common_Result::SUCCESS != code) { SDL_LOG_ERROR("Error is returned. Capabilities won't be updated."); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::Buttons_GetCapabilities); return; } @@ -81,6 +80,9 @@ void ButtonGetCapabilitiesResponse::Run() { [hmi_response::preset_bank_capabilities]); } + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::Buttons_GetCapabilities); + if (!hmi_capabilities_.SaveCachedCapabilitiesToFile( hmi_interface::buttons, sections_to_update, message_->getSchema())) { SDL_LOG_ERROR("Failed to save Buttons.GetCapabilities response to cache"); 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 8229e1978c6..50fb41a5515 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 @@ -59,6 +59,8 @@ void GetSystemInfoResponse::Run() { (*message_)[strings::params][hmi_response::code].asInt()); hmi_capabilities_.set_ccpu_version(policy_handler_.GetCCPUVersionFromPT()); + hmi_capabilities_.set_hardware_version( + policy_handler_.GetHardwareVersionFromPT()); if (hmi_apis::Common_Result::SUCCESS != code) { SDL_LOG_WARN("GetSystemError returns an error code " << code); @@ -72,6 +74,11 @@ void GetSystemInfoResponse::Run() { policy_handler_.OnGetSystemInfo( info.ccpu_version, info.wers_country_code, info.language); + if (!info.hardware_version.empty()) { + policy_handler_.OnHardwareVersionReceived(info.hardware_version); + hmi_capabilities_.set_hardware_version(info.hardware_version); + } + hmi_capabilities_.OnSoftwareVersionReceived(info.ccpu_version); } @@ -89,6 +96,12 @@ const SystemInfo GetSystemInfoResponse::GetSystemInfo() const { info.language = application_manager::EnumToString( static_cast(lang_code)); + if ((*message_)[strings::msg_params].keyExists( + strings::system_hardware_version)) { + info.hardware_version = + (*message_)[strings::msg_params][strings::system_hardware_version] + .asString(); + } return info; } 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 4caa307be3b..850f292972d 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 @@ -75,6 +75,8 @@ void NaviIsReadyRequest::on_event(const event_engine::Event& event) { HMICapabilities& hmi_capabilities = hmi_capabilities_; hmi_capabilities.set_is_navi_cooperating(is_available); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::Navigation_IsReady); break; } default: { @@ -84,6 +86,11 @@ void NaviIsReadyRequest::on_event(const event_engine::Event& event) { } } +void NaviIsReadyRequest::onTimeOut() { + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::Navigation_IsReady); +} + } // namespace commands } // 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 index 7ba330caa8e..56ff20ecc58 100644 --- 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 @@ -34,6 +34,7 @@ #include "application_manager/display_capabilities_builder.h" #include "application_manager/message_helper.h" +#include "extensions/system_capability_app_extension.h" #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" @@ -84,11 +85,7 @@ OnBCSystemCapabilityUpdatedNotificationFromHMI:: SDL_LOG_DEBUG("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); - + RemoveAppIdFromNotification(); auto& builder = app->display_capabilities_builder(); if (builder.IsWaitingForWindowCapabilities(display_capabilities)) { SDL_LOG_DEBUG("Application is waiting for capabilities"); @@ -99,6 +96,54 @@ OnBCSystemCapabilityUpdatedNotificationFromHMI:: return ProcessSystemDisplayCapabilitiesResult::SUCCESS; } +void OnBCSystemCapabilityUpdatedNotificationFromHMI:: + RemoveAppIdFromNotification() { + (*message_)[strings::params][strings::connection_key] = + (*message_)[strings::msg_params][strings::app_id]; + (*message_)[strings::msg_params].erase(strings::app_id); +} + +bool OnBCSystemCapabilityUpdatedNotificationFromHMI:: + ProcessVideoStreamingCapability( + const smart_objects::SmartObject& system_capability) { + if (!system_capability.keyExists(strings::video_streaming_capability)) { + SDL_LOG_WARN( + "VideoStreamingCapability is absent in the notification. " + "Notification Will be ignored"); + return false; + } + if (!(*message_)[strings::msg_params].keyExists(strings::app_id)) { + SDL_LOG_WARN( + "Notification doesn't contain an application id. Will " + "be ignored"); + return false; + } + + const auto app_id = + (*message_)[strings::msg_params][strings::app_id].asUInt(); + + auto app = application_manager_.application(app_id); + if (!app) { + SDL_LOG_WARN("Application with app_id: " + << app_id + << " isn't registered. Notification will be ignored"); + return false; + } + + auto& system_capability_extension = + SystemCapabilityAppExtension::ExtractExtension(*app); + + if (!system_capability_extension.IsSubscribedTo( + mobile_apis::SystemCapabilityType::VIDEO_STREAMING)) { + SDL_LOG_WARN("The Application with app_id: " + << app_id + << " isn't subscribed to the VIDEO_STREAMING system " + "capability type. Notification will be ignored"); + return false; + } + return true; +} + void OnBCSystemCapabilityUpdatedNotificationFromHMI::Run() { SDL_LOG_AUTO_TRACE(); @@ -109,7 +154,11 @@ void OnBCSystemCapabilityUpdatedNotificationFromHMI::Run() { const auto& system_capability = (*message_)[strings::msg_params][strings::system_capability]; - switch (system_capability[strings::system_capability_type].asInt()) { + const auto system_capability_type = + static_cast( + system_capability[strings::system_capability_type].asInt()); + + switch (system_capability_type) { case mobile_apis::SystemCapabilityType::DISPLAYS: { if (system_capability.keyExists(strings::display_capabilities)) { const auto result = ProcessSystemDisplayCapabilities( @@ -135,6 +184,14 @@ void OnBCSystemCapabilityUpdatedNotificationFromHMI::Run() { } break; } + case mobile_apis::SystemCapabilityType::VIDEO_STREAMING: { + if (!ProcessVideoStreamingCapability(system_capability)) { + return; + } + RemoveAppIdFromNotification(); + break; + } + default: { SDL_LOG_ERROR("Unknown system capability type received"); } } SendNotificationToMobile(message_); 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 2440e918b73..02c2ccf31ba 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/hmi/on_navi_way_point_change_notification.cc @@ -32,6 +32,8 @@ #include "sdl_rpc_plugin/commands/hmi/on_navi_way_point_change_notification.h" +#include "application_manager/app_service_manager.h" + namespace sdl_rpc_plugin { using namespace application_manager; @@ -56,8 +58,12 @@ void OnNaviWayPointChangeNotification::Run() { // prepare SmartObject for mobile factory (*message_)[strings::params][strings::function_id] = static_cast(mobile_apis::FunctionID::OnWayPointChangeID); + application_manager_.SaveWayPointsMessage(message_, 0); - SendNotificationToMobile(message_); + if (application_manager_.GetAppServiceManager().FindWayPointsHandler() == + nullptr) { + SendNotificationToMobile(message_); + } } } // namespace commands diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/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 10507a516fc..bd5da04cb3e 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 @@ -58,11 +58,10 @@ void RCGetCapabilitiesResponse::Run() { const auto result_code = static_cast( (*message_)[strings::params][hmi_response::code].asInt()); - hmi_capabilities_.UpdateRequestsRequiredForCapabilities( - hmi_apis::FunctionID::RC_GetCapabilities); - if (hmi_apis::Common_Result::SUCCESS != result_code) { SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities"); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::RC_GetCapabilities); return; } @@ -88,6 +87,9 @@ void RCGetCapabilitiesResponse::Run() { hmi_capabilities_.set_rc_supported(rc_capability_exists); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::RC_GetCapabilities); + if (!hmi_capabilities_.SaveCachedCapabilitiesToFile( hmi_interface::rc, sections_to_update, message_->getSchema())) { SDL_LOG_ERROR("Failed to save RC.GetCapabilities response to cache"); 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 c9a9af87fb2..3d31953474e 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 @@ -79,6 +79,8 @@ void RCIsReadyRequest::on_event(const event_engine::Event& event) { if (!is_available) { hmi_capabilities.set_rc_supported(false); } + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::RC_IsReady); if (!app_mngr::commands::CheckAvailabilityHMIInterfaces( application_manager_, HmiInterfaces::HMI_INTERFACE_RC)) { @@ -99,6 +101,8 @@ void RCIsReadyRequest::on_event(const event_engine::Event& event) { void RCIsReadyRequest::onTimeOut() { // Note(dtrunov): According to new requirment APPLINK-27956 + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::RC_IsReady); RequestInterfaceCapabilities(hmi_interface::rc); } 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 167966e55b6..10709bf94da 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 @@ -57,11 +57,10 @@ void TTSGetCapabilitiesResponse::Run() { const auto result_code = static_cast( (*message_)[strings::params][hmi_response::code].asInt()); - hmi_capabilities_.UpdateRequestsRequiredForCapabilities( - hmi_apis::FunctionID::TTS_GetCapabilities); - if (hmi_apis::Common_Result::SUCCESS != result_code) { SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities"); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::TTS_GetCapabilities); return; } @@ -80,6 +79,9 @@ void TTSGetCapabilitiesResponse::Run() { [hmi_response::prerecorded_speech_capabilities]); } + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::TTS_GetCapabilities); + if (!hmi_capabilities_.SaveCachedCapabilitiesToFile( hmi_interface::tts, sections_to_update, message_->getSchema())) { SDL_LOG_ERROR("Failed to save TTS.GetCapabilities response to cache"); 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 2b14bea6817..8b708dda01f 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 @@ -61,11 +61,10 @@ void TTSGetLanguageResponse::Run() { const Common_Result::eType result_code = static_cast( (*message_)[strings::params][hmi_response::code].asInt()); - hmi_capabilities_.UpdateRequestsRequiredForCapabilities( - hmi_apis::FunctionID::TTS_GetLanguage); - if (Common_Result::SUCCESS != result_code) { SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities"); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::TTS_GetLanguage); return; } @@ -79,6 +78,9 @@ void TTSGetLanguageResponse::Run() { hmi_capabilities_.set_active_tts_language(language); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::TTS_GetLanguage); + std::vector sections_to_update{hmi_response::language}; if (!hmi_capabilities_.SaveCachedCapabilitiesToFile( hmi_interface::tts, sections_to_update, message_->getSchema())) { 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 6b074005b21..71ecd9d4da2 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 @@ -61,17 +61,19 @@ void TTSGetSupportedLanguagesResponse::Run() { static_cast( (*message_)[strings::params][hmi_response::code].asInt()); - hmi_capabilities_.UpdateRequestsRequiredForCapabilities( - hmi_apis::FunctionID::TTS_GetSupportedLanguages); - if (hmi_apis::Common_Result::SUCCESS != code) { SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities"); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::TTS_GetSupportedLanguages); return; } hmi_capabilities_.set_tts_supported_languages( (*message_)[strings::msg_params][hmi_response::languages]); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::TTS_GetSupportedLanguages); + std::vector sections_to_update{hmi_response::languages}; if (!hmi_capabilities_.SaveCachedCapabilitiesToFile( hmi_interface::tts, sections_to_update, message_->getSchema())) { 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 1f1f3e7eabb..5ff7bc5a503 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 @@ -73,6 +73,8 @@ void TTSIsReadyRequest::on_event(const event_engine::Event& event) { application_manager_, message, HmiInterfaces::HMI_INTERFACE_TTS); HMICapabilities& hmi_capabilities = hmi_capabilities_; hmi_capabilities.set_is_tts_cooperating(is_available); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::TTS_IsReady); if (!app_mngr::commands::CheckAvailabilityHMIInterfaces( application_manager_, HmiInterfaces::HMI_INTERFACE_TTS)) { UpdateRequiredInterfaceCapabilitiesRequests(hmi_interface::tts); @@ -92,6 +94,8 @@ void TTSIsReadyRequest::on_event(const event_engine::Event& event) { void TTSIsReadyRequest::onTimeOut() { // Note(dtrunov): According to new requirment APPLINK-27956 + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::TTS_IsReady); RequestInterfaceCapabilities(hmi_interface::tts); } } // namespace commands 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 31dda227094..45c5f59326b 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 @@ -58,11 +58,10 @@ void UIGetCapabilitiesResponse::Run() { const auto result_code = static_cast( (*message_)[strings::params][hmi_response::code].asInt()); - hmi_capabilities_.UpdateRequestsRequiredForCapabilities( - hmi_apis::FunctionID::UI_GetCapabilities); - if (hmi_apis::Common_Result::SUCCESS != result_code) { SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities"); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::UI_GetCapabilities); return; } @@ -165,6 +164,9 @@ void UIGetCapabilitiesResponse::Run() { msg_params[strings::pcm_stream_capabilities]); } + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::UI_GetCapabilities); + if (!hmi_capabilities_.SaveCachedCapabilitiesToFile( hmi_interface::ui, sections_to_update, message_->getSchema())) { SDL_LOG_ERROR("Failed to save UI.GetCapabilities response to cache"); 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 ffeec025beb..9bae80f48ee 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 @@ -61,11 +61,10 @@ void UIGetLanguageResponse::Run() { const Common_Result::eType result_code = static_cast( (*message_)[strings::params][hmi_response::code].asInt()); - hmi_capabilities_.UpdateRequestsRequiredForCapabilities( - hmi_apis::FunctionID::UI_GetLanguage); - if (Common_Result::SUCCESS != result_code) { SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities"); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::UI_GetLanguage); return; } @@ -79,6 +78,9 @@ void UIGetLanguageResponse::Run() { hmi_capabilities_.set_active_ui_language(language); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::UI_GetLanguage); + std::vector sections_to_update{hmi_response::language}; if (!hmi_capabilities_.SaveCachedCapabilitiesToFile( hmi_interface::ui, sections_to_update, message_->getSchema())) { 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 20606294aec..e3d6a979baa 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 @@ -61,17 +61,19 @@ void UIGetSupportedLanguagesResponse::Run() { static_cast( (*message_)[strings::params][hmi_response::code].asInt()); - hmi_capabilities_.UpdateRequestsRequiredForCapabilities( - hmi_apis::FunctionID::UI_GetSupportedLanguages); - if (hmi_apis::Common_Result::SUCCESS != code) { SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities"); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::UI_GetSupportedLanguages); return; } hmi_capabilities_.set_ui_supported_languages( (*message_)[strings::msg_params][hmi_response::languages]); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::UI_GetSupportedLanguages); + std::vector sections_to_update{hmi_response::languages}; if (!hmi_capabilities_.SaveCachedCapabilitiesToFile( hmi_interface::ui, sections_to_update, message_->getSchema())) { 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 d020972ce64..f3da33c5b57 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 @@ -72,6 +72,8 @@ void UIIsReadyRequest::on_event(const event_engine::Event& event) { application_manager_, message, HmiInterfaces::HMI_INTERFACE_UI); HMICapabilities& hmi_capabilities = hmi_capabilities_; hmi_capabilities.set_is_ui_cooperating(is_available); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::UI_IsReady); if (!app_mngr::commands::CheckAvailabilityHMIInterfaces( application_manager_, HmiInterfaces::HMI_INTERFACE_UI)) { UpdateRequiredInterfaceCapabilitiesRequests(hmi_interface::ui); @@ -91,6 +93,8 @@ void UIIsReadyRequest::on_event(const event_engine::Event& event) { void UIIsReadyRequest::onTimeOut() { // Note(dtrunov): According to new requirment APPLINK-27956 + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::UI_IsReady); RequestInterfaceCapabilities(hmi_interface::ui); } 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 c8aa2956459..4d055564deb 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 @@ -53,51 +53,27 @@ UpdateDeviceListRequest::UpdateDeviceListRequest( application_manager, rpc_service, hmi_capabilities, - policy_handle) - , EventObserver(application_manager_.event_dispatcher()) {} + policy_handle) {} UpdateDeviceListRequest::~UpdateDeviceListRequest() {} void UpdateDeviceListRequest::Run() { SDL_LOG_AUTO_TRACE(); - sync_primitives::AutoLock auto_lock(wait_hmi_lock); // Fix problem with SDL and HMI HTML. This problem is not actual for HMI PASA. // Flag conditional compilation for specific customer is used in order to // exclude // hit code to RTC - if (true == application_manager_.get_settings().launch_hmi()) { - if (!application_manager_.IsHMICooperating()) { - SDL_LOG_INFO("Wait for HMI Cooperation"); - subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_OnReady); - termination_condition_.Wait(auto_lock); - SDL_LOG_DEBUG("HMI Cooperation OK"); + if (application_manager_.get_settings().launch_hmi()) { + SDL_LOG_INFO("Wait for HMI Cooperation"); + if (!application_manager_.WaitForHmiIsReady()) { + SDL_LOG_ERROR("HMI is not ready"); + return; } - } - - SendRequest(); -} -void UpdateDeviceListRequest::on_event(const event_engine::Event& event) { - SDL_LOG_AUTO_TRACE(); - sync_primitives::AutoLock auto_lock(wait_hmi_lock); - switch (event.id()) { - case hmi_apis::FunctionID::BasicCommunication_OnReady: { - SDL_LOG_INFO("received OnReady"); - unsubscribe_from_event(hmi_apis::FunctionID::BasicCommunication_OnReady); - termination_condition_.Broadcast(); - break; - }; - default: { - SDL_LOG_ERROR("Unknown event " << event.id()); - break; - }; + SDL_LOG_DEBUG("HMI Cooperation is OK"); } -} -bool UpdateDeviceListRequest::CleanUp() { - sync_primitives::AutoLock auto_lock(wait_hmi_lock); - termination_condition_.Broadcast(); - return true; + SendRequest(); } } // namespace commands 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 315107d94a4..60cb39f987b 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 @@ -57,11 +57,10 @@ void VRGetCapabilitiesResponse::Run() { const auto result_code = static_cast( (*message_)[strings::params][hmi_response::code].asInt()); - hmi_capabilities_.UpdateRequestsRequiredForCapabilities( - hmi_apis::FunctionID::VR_GetCapabilities); - if (hmi_apis::Common_Result::SUCCESS != result_code) { SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities"); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::VR_GetCapabilities); return; } @@ -74,6 +73,9 @@ void VRGetCapabilitiesResponse::Run() { hmi_capabilities_.set_vr_capabilities(msg_params[strings::vr_capabilities]); } + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::VR_GetCapabilities); + if (!hmi_capabilities_.SaveCachedCapabilitiesToFile( hmi_interface::vr, sections_to_update, message_->getSchema())) { SDL_LOG_ERROR("Failed to save VR.GetCapabilities response to cache"); 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 e8c881f6f83..3529d9fcde0 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 @@ -61,11 +61,10 @@ void VRGetLanguageResponse::Run() { const Common_Result::eType result_code = static_cast( (*message_)[strings::params][hmi_response::code].asInt()); - hmi_capabilities_.UpdateRequestsRequiredForCapabilities( - hmi_apis::FunctionID::VR_GetLanguage); - if (Common_Result::SUCCESS != result_code) { SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities"); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::VR_GetLanguage); return; } @@ -79,6 +78,9 @@ void VRGetLanguageResponse::Run() { hmi_capabilities_.set_active_vr_language(language); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::VR_GetLanguage); + std::vector sections_to_update{hmi_response::language}; if (!hmi_capabilities_.SaveCachedCapabilitiesToFile( hmi_interface::vr, sections_to_update, message_->getSchema())) { 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 72278fcdddd..7b234befbe5 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 @@ -62,20 +62,24 @@ void VRGetSupportedLanguagesResponse::Run() { static_cast( (*message_)[strings::params][hmi_response::code].asInt()); + if (hmi_apis::Common_Result::SUCCESS != code) { + SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities"); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::VR_GetSupportedLanguages); + return; + } + + HMICapabilities& hmi_capabilities = hmi_capabilities_; + hmi_capabilities.set_vr_supported_languages( + (*message_)[strings::msg_params][hmi_response::languages]); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( hmi_apis::FunctionID::VR_GetSupportedLanguages); - if (hmi_apis::Common_Result::SUCCESS == code) { - HMICapabilities& hmi_capabilities = hmi_capabilities_; - hmi_capabilities.set_vr_supported_languages( - (*message_)[strings::msg_params][hmi_response::languages]); - - std::vector sections_to_update{hmi_response::languages}; - if (!hmi_capabilities_.SaveCachedCapabilitiesToFile( - hmi_interface::vr, sections_to_update, message_->getSchema())) { - SDL_LOG_ERROR( - "Failed to save VR.GetSupportedLanguages response to cache"); - } + std::vector sections_to_update{hmi_response::languages}; + if (!hmi_capabilities_.SaveCachedCapabilitiesToFile( + hmi_interface::vr, sections_to_update, message_->getSchema())) { + SDL_LOG_ERROR("Failed to save VR.GetSupportedLanguages response to cache"); } } 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 303e7a68437..2efd227adde 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 @@ -73,6 +73,8 @@ void VRIsReadyRequest::on_event(const event_engine::Event& event) { HMICapabilities& hmi_capabilities = hmi_capabilities_; hmi_capabilities.set_is_vr_cooperating(is_available); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::VR_IsReady); if (!app_mngr::commands::CheckAvailabilityHMIInterfaces( application_manager_, HmiInterfaces::HMI_INTERFACE_VR)) { UpdateRequiredInterfaceCapabilitiesRequests(hmi_interface::vr); @@ -92,6 +94,8 @@ void VRIsReadyRequest::on_event(const event_engine::Event& event) { void VRIsReadyRequest::onTimeOut() { // Note(dtrunov): According to new requirment APPLINK-27956 + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::VR_IsReady); RequestInterfaceCapabilities(hmi_interface::vr); } 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 6717f332f89..03b0ee20fc0 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 @@ -107,6 +107,20 @@ void AddCommandRequest::Run() { } } + if ((*message_)[strings::msg_params].keyExists(strings::secondary_image)) { + mobile_apis::Result::eType verification_result = MessageHelper::VerifyImage( + (*message_)[strings::msg_params][strings::secondary_image], + app, + application_manager_); + + if (mobile_apis::Result::INVALID_DATA == verification_result) { + SDL_LOG_ERROR("MessageHelper::VerifyImage return " + << verification_result); + SendResponse(false, verification_result); + return; + } + } + if (!((*message_)[strings::msg_params].keyExists(strings::cmd_id))) { SDL_LOG_ERROR("INVALID_DATA"); SendResponse(false, mobile_apis::Result::INVALID_DATA); @@ -127,10 +141,6 @@ void AddCommandRequest::Run() { bool data_exist = false; if ((*message_)[strings::msg_params].keyExists(strings::menu_params)) { - if (!CheckCommandName(app)) { - SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); - return; - } if (((*message_)[strings::msg_params][strings::menu_params].keyExists( hmi_request::parent_id)) && (0 != (*message_)[strings::msg_params][strings::menu_params] @@ -191,6 +201,17 @@ void AddCommandRequest::Run() { (*message_)[strings::msg_params][strings::cmd_icon]; } + if (((*message_)[strings::msg_params].keyExists( + strings::secondary_image)) && + ((*message_)[strings::msg_params][strings::secondary_image].keyExists( + strings::value)) && + (0 < (*message_)[strings::msg_params][strings::secondary_image] + [strings::value] + .length())) { + ui_msg_params[strings::secondary_image] = + (*message_)[strings::msg_params][strings::secondary_image]; + } + send_ui_ = true; } @@ -220,47 +241,6 @@ void AddCommandRequest::Run() { } } -bool AddCommandRequest::CheckCommandName(ApplicationConstSharedPtr app) { - if (!app) { - return false; - } - - const DataAccessor accessor = app->commands_map(); - const CommandsMap& commands = accessor.GetData(); - CommandsMap::const_iterator i = commands.begin(); - uint32_t saved_parent_id = 0; - uint32_t parent_id = 0; - 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(); - } - - for (; commands.end() != i; ++i) { - if (!(*i->second).keyExists(strings::menu_params)) { - continue; - } - - saved_parent_id = 0; - if ((*i->second)[strings::menu_params].keyExists(hmi_request::parent_id)) { - saved_parent_id = - (*i->second)[strings::menu_params][hmi_request::parent_id].asUInt(); - } - if (((*i->second)[strings::menu_params][strings::menu_name].asString() == - (*message_)[strings::msg_params][strings::menu_params] - [strings::menu_name] - .asString()) && - (saved_parent_id == parent_id)) { - SDL_LOG_INFO( - "AddCommandRequest::CheckCommandName received" - " command name already exist in same level menu"); - return false; - } - } - return true; -} - bool AddCommandRequest::CheckCommandVRSynonym(ApplicationConstSharedPtr app) { if (!app) { return false; @@ -565,6 +545,16 @@ bool AddCommandRequest::IsWhiteSpaceExist() { return true; } } + + if ((*message_)[strings::msg_params].keyExists(strings::secondary_image)) { + str = (*message_)[strings::msg_params][strings::secondary_image] + [strings::value] + .asCharArray(); + if (!CheckSyntax(str)) { + SDL_LOG_ERROR("Invalid secondaryImage value syntax check failed"); + return true; + } + } return false; } 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 e2a37f17bd9..309f07e4438 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 @@ -86,6 +86,20 @@ void AddSubMenuRequest::Run() { } } + if (received_msg_params.keyExists(strings::secondary_image)) { + verification_result = MessageHelper::VerifyImage( + received_msg_params[strings::secondary_image], + app, + application_manager_); + + if (mobile_apis::Result::INVALID_DATA == verification_result) { + SDL_LOG_ERROR("MessageHelper::VerifyImage return " + << verification_result); + SendResponse(false, verification_result); + return; + } + } + const int32_t menu_id = received_msg_params[strings::menu_id].asInt(); const auto sub_menu = app->FindSubMenu(menu_id); @@ -114,12 +128,6 @@ void AddSubMenuRequest::Run() { const std::string& menu_name = received_msg_params[strings::menu_name].asString(); - if (app->IsSubMenuNameAlreadyExist(menu_name, parent_id)) { - SDL_LOG_ERROR("Menu name " << menu_name << " is duplicated."); - SendResponse(false, mobile_apis::Result::DUPLICATE_NAME); - return; - } - if (!CheckSubMenuName()) { SDL_LOG_ERROR("Sub-menu name is not valid."); SendResponse(false, mobile_apis::Result::INVALID_DATA); @@ -148,11 +156,23 @@ void AddSubMenuRequest::Run() { if (received_msg_params.keyExists(strings::menu_icon)) { msg_params[strings::menu_icon] = received_msg_params[strings::menu_icon]; } + if (received_msg_params.keyExists(strings::secondary_image)) { + msg_params[strings::secondary_image] = + received_msg_params[strings::secondary_image]; + } msg_params[strings::menu_params][strings::menu_name] = received_msg_params[strings::menu_name]; if (received_msg_params.keyExists(strings::parent_id)) { msg_params[strings::menu_params][strings::parent_id] = parent_id; } + if (received_msg_params.keyExists(strings::secondary_text)) { + msg_params[strings::menu_params][strings::secondary_text] = + received_msg_params[strings::secondary_text]; + } + if (received_msg_params.keyExists(strings::tertiary_text)) { + msg_params[strings::menu_params][strings::tertiary_text] = + received_msg_params[strings::tertiary_text]; + } msg_params[strings::app_id] = app->app_id(); 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 47b3a87d52a..8728bb44036 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 @@ -144,6 +144,7 @@ void AlertManeuverRequest::Run() { smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); + msg_params[strings::app_id] = app->app_id(); msg_params[hmi_request::tts_chunks] = (*message_)[strings::msg_params][strings::tts_chunks]; msg_params[hmi_request::speak_type] = @@ -236,7 +237,8 @@ bool AlertManeuverRequest::PrepareResponseParameters( application_manager_.hmi_interfaces().GetInterfaceState( HmiInterfaces::HMI_INTERFACE_TTS)))) { result_code = mobile_apis::Result::WARNINGS; - return_info = std::string("Unsupported phoneme type sent in a prompt"); + return_info = app_mngr::commands::MergeInfos( + navigation_alert_info, info_navi_, tts_alert_info, info_tts_); return result; } result_code = 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 993dc755482..5661b1df9c7 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 @@ -59,6 +59,8 @@ AlertManeuverResponse::~AlertManeuverResponse() {} void AlertManeuverResponse::Run() { SDL_LOG_AUTO_TRACE(); + application_manager_.UnsubscribeAppFromSoftButtons(message_); + rpc_service_.SendMessageToMobile(message_); } 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 cfd3106f4da..9f04541b46e 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 @@ -213,19 +213,10 @@ bool AlertRequest::PrepareResponseParameters( bool result = PrepareResultForMobileResponse(ui_alert_info, tts_alert_info); - /* result=false if UI interface is ok and TTS interface = UNSUPPORTED_RESOURCE - * and sdl receive TTS.IsReady=true or SDL doesn't receive responce for - * TTS.IsReady. - */ - if (result && ui_alert_info.is_ok && tts_alert_info.is_unsupported_resource && - HmiInterfaces::STATE_NOT_AVAILABLE != tts_alert_info.interface_state) { - result = false; - } result_code = mobile_apis::Result::WARNINGS; if ((ui_alert_info.is_ok || ui_alert_info.is_not_used) && tts_alert_info.is_unsupported_resource && HmiInterfaces::STATE_AVAILABLE == tts_alert_info.interface_state) { - tts_response_info_ = "Unsupported phoneme type sent in a prompt"; info = app_mngr::commands::MergeInfos( ui_alert_info, ui_response_info_, tts_alert_info, tts_response_info_); return result; @@ -234,7 +225,10 @@ bool AlertRequest::PrepareResponseParameters( info = app_mngr::commands::MergeInfos( ui_alert_info, ui_response_info_, tts_alert_info, tts_response_info_); // Mobile Alert request is successful when UI_Alert is successful - if (is_ui_alert_sent_ && !ui_alert_info.is_ok) { + bool has_unsupported_data = + ui_alert_info.is_unsupported_resource && + HmiInterfaces::STATE_NOT_AVAILABLE != ui_alert_info.interface_state; + if (is_ui_alert_sent_ && !ui_alert_info.is_ok && !has_unsupported_data) { return false; } return result; 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 1b8eebe7d7e..84d23bec466 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 @@ -61,6 +61,8 @@ AlertResponse::~AlertResponse() {} void AlertResponse::Run() { SDL_LOG_AUTO_TRACE(); + application_manager_.UnsubscribeAppFromSoftButtons(message_); + rpc_service_.SendMessageToMobile(message_); } 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 1cd4806f7ec..64eae885a85 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 @@ -204,10 +204,12 @@ void GetSystemCapabilityRequest::Run() { auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app); if ((*message_)[app_mngr::strings::msg_params][strings::subscribe] .asBool() == true) { - SDL_LOG_DEBUG("Subscribe to system capability: " << response_type); + SDL_LOG_DEBUG("Subscribe to system capability: " + << response_type << " for app_id: " << app->app_id()); ext.SubscribeTo(response_type); } else { - SDL_LOG_DEBUG("Unsubscribe from system capability: " << response_type); + SDL_LOG_DEBUG("Unsubscribe from system capability: " + << response_type << " for app_id: " << app->app_id()); ext.UnsubscribeFrom(response_type); } } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_capability_updated_notification.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_capability_updated_notification.cc new file mode 100644 index 00000000000..c04b10cbd45 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_app_capability_updated_notification.cc @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2020, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/on_app_capability_updated_notification.h" + +namespace sdl_rpc_plugin { + +namespace commands { +namespace mobile { + +SDL_CREATE_LOG_VARIABLE("Commands") + +OnAppCapabilityUpdatedNotification::OnAppCapabilityUpdatedNotification( + const application_manager::commands::MessageSharedPtr& message, + app_mngr::ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handle) + : CommandNotificationFromMobileImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handle) {} + +OnAppCapabilityUpdatedNotification::~OnAppCapabilityUpdatedNotification() {} + +void OnAppCapabilityUpdatedNotification::Run() { + SDL_LOG_AUTO_TRACE(); + app_mngr::ApplicationSharedPtr app = + application_manager_.application(connection_key()); + + if (!app) { + SDL_LOG_ERROR("No application associated with session key"); + return; + } + + (*message_)[app_mngr::strings::msg_params][app_mngr::strings::app_id] = + app->app_id(); + + SendNotificationToHMI( + hmi_apis::FunctionID::BasicCommunication_OnAppCapabilityUpdated); +} + +} // namespace mobile +} // namespace commands +} // 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 850aa64b5fd..1f15170ffe0 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 @@ -81,15 +81,10 @@ void OnSystemCapabilityUpdatedNotification::Run() { } break; } - case mobile_apis::SystemCapabilityType::VIDEO_STREAMING: - if (hmi_capabilities_.video_streaming_capability()) { - msg_params[strings::system_capability] - [strings::video_streaming_capability] = - *hmi_capabilities_.video_streaming_capability(); - } else { - return; - } - break; + case mobile_apis::SystemCapabilityType::VIDEO_STREAMING: { + SendNotification(); + return; + } case mobile_apis::SystemCapabilityType::APP_SERVICES: { auto all_services = application_manager_.GetAppServiceManager().GetAllServiceRecords(); @@ -200,48 +195,51 @@ void OnSystemCapabilityUpdatedNotification::Run() { for (; applications.end() != app_it; ++app_it) { const ApplicationSharedPtr app = *app_it; - if (system_capability_type == - mobile_apis::SystemCapabilityType::REMOTE_CONTROL && - !app->is_remote_control_supported()) { - SDL_LOG_WARN( - "App with connection key: " - << app->app_id() - << " was subcribed to REMOTE_CONTROL system capabilities, but " - "does not have RC permissions. Unsubscribing"); - auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app); - ext.UnsubscribeFrom(system_capability_type); - continue; - } - if (mobile_apis::SystemCapabilityType::DISPLAYS == system_capability_type) { - SDL_LOG_DEBUG("Using common display capabilities"); - auto capabilities = hmi_capabilities_.system_display_capabilities(); - - auto& builder = app->display_capabilities_builder(); - if (app->is_resuming() && builder.IsWindowResumptionNeeded()) { - SDL_LOG_DEBUG("Application " - << app->app_id() - << " is resuming. Providing cached capabilities"); - auto display_caps = builder.display_capabilities(); - capabilities = display_caps; - } else if (app->display_capabilities()) { - SDL_LOG_DEBUG("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); - } + switch (system_capability_type) { + case mobile_apis::SystemCapabilityType::REMOTE_CONTROL: { + if (!app->is_remote_control_supported()) { + SDL_LOG_WARN("App with connection key: " + << app->app_id() + << " was subcribed to REMOTE_CONTROL system " + "capabilities, but " + "does not have RC permissions. Unsubscribing"); + auto& ext = SystemCapabilityAppExtension::ExtractExtension(*app); + ext.UnsubscribeFrom(system_capability_type); + } + } break; + + case mobile_apis::SystemCapabilityType::DISPLAYS: { + SDL_LOG_DEBUG("Using common display capabilities"); + auto capabilities = hmi_capabilities_.system_display_capabilities(); + auto& builder = app->display_capabilities_builder(); + if (app->is_resuming() && builder.IsWindowResumptionNeeded()) { + SDL_LOG_DEBUG("Application " + << app->app_id() + << " is resuming. Providing cached capabilities"); + auto display_caps = builder.display_capabilities(); + capabilities = display_caps; + } else if (app->display_capabilities()) { + SDL_LOG_DEBUG("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) { - SDL_LOG_WARN("No available display capabilities for sending. Skipping"); - continue; - } + if (!capabilities) { + SDL_LOG_WARN( + "No available display capabilities for sending. Skipping"); + continue; + } - msg_params[strings::system_capability][strings::display_capabilities] = - *capabilities; + msg_params[strings::system_capability][strings::display_capabilities] = + *capabilities; + } break; + default: { SDL_LOG_ERROR("Unknown system capability type"); } } SDL_LOG_INFO("Sending OnSystemCapabilityUpdated " << capability_type_string 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 4a97d5b9709..40705491fc0 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 @@ -109,15 +109,8 @@ void OnSystemRequestNotification::Run() { SDL_LOG_DEBUG("Processing Request type : " << stringified_request_type); - const bool binary_data_is_required = - Compare( - request_type, - mobile_apis::RequestType::PROPRIETARY, - mobile_apis::RequestType::OEM_SPECIFIC); - BinaryMessage binary_data; - if (binary_data_is_required && - (*message_)[strings::msg_params].keyExists(strings::file_name)) { + if ((*message_)[strings::msg_params].keyExists(strings::file_name)) { const std::string filename = (*message_)[strings::msg_params][strings::file_name].asString(); file_system::ReadBinaryFile(filename, binary_data); @@ -126,22 +119,15 @@ void OnSystemRequestNotification::Run() { binary_data = (*message_)[strings::params][strings::binary_data].asBinary(); } - if (mobile_apis::RequestType::OEM_SPECIFIC == request_type) { - (*message_)[strings::params][strings::binary_data] = binary_data; - } else if (mobile_apis::RequestType::PROPRIETARY == request_type) { + 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 we don't save the PT to file - we put it directly in binary_data */ + If the requestType = HTTP, add to mobile API fileType = BINARY" */ #if defined(PROPRIETARY_MODE) AddHeader(binary_data); #endif // PROPRIETARY_MODE -#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) - (*message_)[strings::params][strings::binary_data] = binary_data; -#endif // PROPRIETARY_MODE - (*message_)[strings::msg_params][strings::file_type] = FileType::JSON; } else if (mobile_apis::RequestType::HTTP == request_type) { (*message_)[strings::msg_params][strings::file_type] = FileType::BINARY; @@ -150,13 +136,21 @@ void OnSystemRequestNotification::Run() { policy_handler.TimeoutExchangeSec(); } } else if (mobile_apis::RequestType::LOCK_SCREEN_ICON_URL == request_type) { - if (!(*message_)[strings::msg_params].keyExists(strings::url) || - (*message_)[strings::msg_params][strings::url].empty()) { - SDL_LOG_ERROR("discarding LOCK_SCREEN_ICON_URL request without URL"); + if (binary_data.empty() && + (!(*message_)[strings::msg_params].keyExists(strings::url) || + (*message_)[strings::msg_params][strings::url].empty())) { + SDL_LOG_ERROR( + "discarding LOCK_SCREEN_ICON_URL request with no URL or data"); return; } } +#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) + if (!binary_data.empty()) { + (*message_)[strings::params][strings::binary_data] = binary_data; + } +#endif // PROPRIETARY_MODE + SendNotification(); } 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 33413f805dc..4aa0d9c630f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification.cc @@ -67,7 +67,6 @@ void OnWayPointChangeNotification::Run() { (*message_)[strings::params][strings::connection_key] = *app_id; SendNotification(); } - application_manager_.SaveWayPointsMessage(message_); } } // namespace commands } // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification_from_mobile.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification_from_mobile.cc new file mode 100644 index 00000000000..ad1b0c7ef76 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/on_way_point_change_notification_from_mobile.cc @@ -0,0 +1,90 @@ +/* + Copyright (c) 2020, Ford Motor Company + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following + disclaimer in the documentation and/or other materials provided with the + distribution. + + Neither the name of the Ford Motor Company nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + +#include "sdl_rpc_plugin/commands/mobile/on_way_point_change_notification_from_mobile.h" + +#include "application_manager/app_service_manager.h" +#include "application_manager/message.h" +#include "application_manager/message_helper.h" + +namespace sdl_rpc_plugin { +using namespace application_manager; +namespace commands { + +SDL_CREATE_LOG_VARIABLE("Commands") + +OnWayPointChangeNotificationFromMobile::OnWayPointChangeNotificationFromMobile( + const application_manager::commands::MessageSharedPtr& message, + ApplicationManager& application_manager, + app_mngr::rpc_service::RPCService& rpc_service, + app_mngr::HMICapabilities& hmi_capabilities, + policy::PolicyHandlerInterface& policy_handler) + : CommandNotificationFromMobileImpl(message, + application_manager, + rpc_service, + hmi_capabilities, + policy_handler) {} + +OnWayPointChangeNotificationFromMobile:: + ~OnWayPointChangeNotificationFromMobile() {} + +void OnWayPointChangeNotificationFromMobile::Run() { + SDL_LOG_AUTO_TRACE(); + + (*message_)[strings::params][strings::message_type] = + static_cast(application_manager::MessageType::kNotification); + ApplicationSharedPtr app = application_manager_.application(connection_key()); + + if (app.use_count() == 0) { + SDL_LOG_ERROR( + "OnWayPointChangeNotificationFromMobile application doesn't exist"); + return; + } + + auto service = + application_manager_.GetAppServiceManager().FindWayPointsHandler(); + if (!service || !service->mobile_service || + service->connection_key != connection_key()) { + SDL_LOG_ERROR("Application is not active NAVIGATION ASP"); + return; + } + + application_manager_.SaveWayPointsMessage(message_, connection_key()); + + (*message_)[strings::params][strings::message_type] = + static_cast(application_manager::MessageType::kNotification); + rpc_service_.ManageMobileCommand(message_, SOURCE_SDL); +} + +} // namespace commands + +} // namespace sdl_rpc_plugin diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/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 5918c05f2d2..0accdd1e76c 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 @@ -224,20 +224,17 @@ PerformAudioPassThruRequest::PrepareResponseParameters() { HmiInterfaces::HMI_INTERFACE_TTS, application_manager_); - // Note(dtrunov): According to requirment "WARNINGS, success:true on getting - // UNSUPPORTED_RESOURCE for "ttsChunks" + response_params_.success = + PrepareResultForMobileResponse(ui_perform_info, tts_perform_info); if (ui_perform_info.is_ok && tts_perform_info.is_unsupported_resource && HmiInterfaces::STATE_AVAILABLE == tts_perform_info.interface_state) { response_params_.result_code = mobile_apis::Result::WARNINGS; - tts_info_ = "Unsupported phoneme type sent in a prompt"; response_params_.info = app_mngr::commands::MergeInfos( ui_perform_info, ui_info_, tts_perform_info, tts_info_); response_params_.success = true; return response_params_; } - response_params_.success = - PrepareResultForMobileResponse(ui_perform_info, tts_perform_info); if (IsResultCodeUnsupported(ui_perform_info, tts_perform_info)) { response_params_.result_code = mobile_apis::Result::UNSUPPORTED_RESOURCE; } else { 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 a3269847a19..bb990574bd6 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 @@ -195,8 +195,7 @@ void PerformInteractionRequest::Run() { switch (interaction_mode_) { case mobile_apis::InteractionMode::BOTH: { SDL_LOG_DEBUG("Interaction Mode: BOTH"); - if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) || - !CheckVrHelpItemPositions(app) || + if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app) || !CheckChoiceSetListVRCommands(app)) { return; } @@ -204,8 +203,7 @@ void PerformInteractionRequest::Run() { } case mobile_apis::InteractionMode::MANUAL_ONLY: { SDL_LOG_DEBUG("Interaction Mode: MANUAL_ONLY"); - if (!CheckChoiceSetVRSynonyms(app) || !CheckChoiceSetMenuNames(app) || - !CheckVrHelpItemPositions(app)) { + if (!CheckChoiceSetVRSynonyms(app) || !CheckVrHelpItemPositions(app)) { return; } break; @@ -253,7 +251,7 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) { ui_result_code_ = static_cast( message[strings::params][hmi_response::code].asUInt()); GetInfo(message, ui_info_); - ProcessUIResponse(event.smart_object(), response_msg_params); + ProcessUIResponse(event.smart_object()); break; } case hmi_apis::FunctionID::VR_PerformInteraction: { @@ -265,7 +263,7 @@ void PerformInteractionRequest::on_event(const event_engine::Event& event) { vr_result_code_ = static_cast( message[strings::params][hmi_response::code].asUInt()); GetInfo(message, vr_info_); - if (ProcessVRResponse(event.smart_object(), response_msg_params)) { + if (ProcessVRResponse(event.smart_object())) { return; } break; @@ -328,8 +326,7 @@ void PerformInteractionRequest::onTimeOut() { } bool PerformInteractionRequest::ProcessVRResponse( - const smart_objects::SmartObject& message, - smart_objects::SmartObject& msg_params) { + const smart_objects::SmartObject& message) { SDL_LOG_AUTO_TRACE(); using namespace hmi_apis; using namespace mobile_apis; @@ -343,9 +340,6 @@ bool PerformInteractionRequest::ProcessVRResponse( return false; } - msg_params[strings::trigger_source] = - static_cast(TriggerSource::TS_VR); - const bool is_vr_aborted_timeout = Compare( vr_result_code_, Common_Result::ABORTED, Common_Result::TIMED_OUT); @@ -403,8 +397,7 @@ bool PerformInteractionRequest::ProcessVRResponse( } void PerformInteractionRequest::ProcessUIResponse( - const smart_objects::SmartObject& message, - smart_objects::SmartObject& msg_params) { + const smart_objects::SmartObject& message) { SDL_LOG_AUTO_TRACE(); using namespace helpers; using namespace smart_objects; @@ -436,38 +429,30 @@ void PerformInteractionRequest::ProcessUIResponse( ui_result_code_, hmi_apis::Common_Result::UNSUPPORTED_RESOURCE); if (result) { + const smart_objects::SmartObject& hmi_msg_params = + message[strings::msg_params]; if (is_pi_unsupported) { ui_result_code_ = hmi_apis::Common_Result::UNSUPPORTED_RESOURCE; ui_info_ = message[strings::msg_params][strings::info].asString(); - } else { - if (message.keyExists(strings::msg_params)) { - msg_params = message[strings::msg_params]; - } - if (is_pi_warning) { - ui_result_code_ = hmi_apis::Common_Result::WARNINGS; - ui_info_ = message[strings::msg_params][strings::info].asString(); - } + } else if (is_pi_warning) { + ui_result_code_ = hmi_apis::Common_Result::WARNINGS; + ui_info_ = message[strings::msg_params][strings::info].asString(); } // result code must be GENERIC_ERROR in case wrong choice_id - if (msg_params.keyExists(strings::choice_id)) { + if (hmi_msg_params.keyExists(strings::choice_id)) { const std::int32_t ui_choice_id = - static_cast(msg_params[strings::choice_id].asInt()); + static_cast(hmi_msg_params[strings::choice_id].asInt()); if (!CheckChoiceIDFromResponse(app, ui_choice_id)) { ui_result_code_ = hmi_apis::Common_Result::GENERIC_ERROR; ui_info_ = "Wrong choiceID was received from HMI"; } else { ui_choice_id_received_ = ui_choice_id; - msg_params[strings::trigger_source] = - mobile_apis::TriggerSource::TS_MENU; - } - } else if (msg_params.keyExists(strings::manual_text_entry)) { - msg_params[strings::trigger_source] = - mobile_apis::TriggerSource::TS_KEYBOARD; - if (msg_params[strings::manual_text_entry].empty()) { - msg_params.erase(strings::manual_text_entry); } + } else if (hmi_msg_params.keyExists(strings::manual_text_entry)) { + ui_text_entry_received_ = + hmi_msg_params[strings::manual_text_entry].asString(); } } } @@ -696,60 +681,6 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( hmi_apis::FunctionID::VR_PerformInteraction, &msg_params, true); } -bool PerformInteractionRequest::CheckChoiceSetMenuNames( - application_manager::ApplicationSharedPtr const app) { - SDL_LOG_AUTO_TRACE(); - - smart_objects::SmartObject& choice_list = - (*message_)[strings::msg_params][strings::interaction_choice_set_id_list]; - - for (size_t i = 0; i < choice_list.length(); ++i) { - // choice_set contains SmartObject msg_params - smart_objects::SmartObject i_choice_set = - app->FindChoiceSet(choice_list[i].asInt()); - - for (size_t j = 0; j < choice_list.length(); ++j) { - smart_objects::SmartObject j_choice_set = - app->FindChoiceSet(choice_list[j].asInt()); - - if (i == j) { - // skip check the same element - continue; - } - - if ((smart_objects::SmartType_Null == i_choice_set.getType()) || - (smart_objects::SmartType_Null == j_choice_set.getType())) { - SDL_LOG_ERROR("Invalid ID"); - SendResponse(false, mobile_apis::Result::INVALID_ID); - return false; - } - - size_t ii = 0; - size_t jj = 0; - for (; ii < i_choice_set[strings::choice_set].length(); ++ii) { - for (; jj < j_choice_set[strings::choice_set].length(); ++jj) { - const std::string& ii_menu_name = - i_choice_set[strings::choice_set][ii][strings::menu_name] - .asString(); - const std::string& jj_menu_name = - j_choice_set[strings::choice_set][jj][strings::menu_name] - .asString(); - - if (ii_menu_name == jj_menu_name) { - SDL_LOG_ERROR("Choice set has duplicated menu name"); - SendResponse(false, - mobile_apis::Result::DUPLICATE_NAME, - "Choice set has duplicated menu name"); - return false; - } - } - } - } - } - - return true; -} - bool PerformInteractionRequest::CheckChoiceSetVRSynonyms( application_manager::ApplicationSharedPtr const app) { SDL_LOG_AUTO_TRACE(); @@ -1124,7 +1055,8 @@ PerformInteractionRequest::PrepareResultCodeForResponse( if (INVALID_CHOICE_ID != vr_choice_id_received_) { return mobile_vr_result_code; } - if (INVALID_CHOICE_ID != ui_choice_id_received_) { + if (INVALID_CHOICE_ID != ui_choice_id_received_ || + !ui_text_entry_received_.empty()) { return mobile_ui_result_code; } @@ -1135,14 +1067,29 @@ PerformInteractionRequest::PrepareResultCodeForResponse( bool PerformInteractionRequest::PrepareResultForMobileResponse( app_mngr::commands::ResponseInfo& ui_response, app_mngr::commands::ResponseInfo& vr_response) const { + bool vr_choice_received = INVALID_CHOICE_ID != vr_choice_id_received_; + bool ui_choice_received = INVALID_CHOICE_ID != ui_choice_id_received_ || + !ui_text_entry_received_.empty(); + + bool vr_response_success = + vr_response.is_ok || + (vr_response.is_unsupported_resource && + vr_response.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE && + vr_choice_received); + bool ui_response_success = + ui_response.is_ok || + (ui_response.is_unsupported_resource && + ui_response.interface_state != HmiInterfaces::STATE_NOT_AVAILABLE && + ui_choice_received); + if (mobile_apis::InteractionMode::VR_ONLY == interaction_mode_) { - return vr_response.is_ok; + return vr_response_success; } if (mobile_apis::InteractionMode::MANUAL_ONLY == interaction_mode_) { - return ui_response.is_ok; + return ui_response_success; } - return (vr_response.is_ok || ui_response.is_ok); + return (vr_response_success || ui_response_success); } bool PerformInteractionRequest::SetChoiceIdToResponseMsgParams( @@ -1151,27 +1098,27 @@ bool PerformInteractionRequest::SetChoiceIdToResponseMsgParams( const bool ui_choice_id_valid = INVALID_CHOICE_ID != ui_choice_id_received_; const bool vr_choice_id_valid = INVALID_CHOICE_ID != vr_choice_id_received_; - if (ui_choice_id_valid && vr_choice_id_valid && ui_choice_id_received_ != vr_choice_id_received_) { return false; } - switch (interaction_mode_) { - case mobile_apis::InteractionMode::eType::MANUAL_ONLY: - if (ui_choice_id_valid) { - msg_param[strings::choice_id] = ui_choice_id_received_; - } - case mobile_apis::InteractionMode::eType::VR_ONLY: - if (vr_choice_id_valid) { - msg_param[strings::choice_id] = vr_choice_id_received_; - } - default: - if (ui_choice_id_valid) { - msg_param[strings::choice_id] = ui_choice_id_received_; - } else if (vr_choice_id_valid) { - msg_param[strings::choice_id] = vr_choice_id_received_; - } + if (!ui_text_entry_received_.empty()) { + msg_param[strings::trigger_source] = + mobile_apis::TriggerSource::TS_KEYBOARD; + msg_param[strings::manual_text_entry] = ui_text_entry_received_; + return true; + } + + if (ui_choice_id_valid && + interaction_mode_ != mobile_apis::InteractionMode::eType::VR_ONLY) { + msg_param[strings::trigger_source] = mobile_apis::TriggerSource::TS_MENU; + msg_param[strings::choice_id] = ui_choice_id_received_; + } else if (vr_choice_id_valid && + interaction_mode_ != + mobile_apis::InteractionMode::eType::MANUAL_ONLY) { + msg_param[strings::trigger_source] = mobile_apis::TriggerSource::TS_VR; + msg_param[strings::choice_id] = vr_choice_id_received_; } return true; 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 6ac830c378b..920805be7ce 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 @@ -159,18 +159,6 @@ uint32_t RegisterAppInterfaceRequest::default_timeout() const { return 0; } -void RegisterAppInterfaceRequest::WaitForHMIIsReady() { - while (!application_manager_.IsStopping() && - !application_manager_.IsHMICooperating()) { - SDL_LOG_DEBUG("Waiting for the HMI... conn_key=" - << connection_key() << ", correlation_id=" << correlation_id() - << ", default_timeout=" << default_timeout() - << ", thread=" << pthread_self()); - sleep(1); - // TODO(DK): timer_->StartWait(1); - } -} - void RegisterAppInterfaceRequest::FillApplicationParams( ApplicationSharedPtr application) { SDL_LOG_AUTO_TRACE(); @@ -488,10 +476,8 @@ void RegisterAppInterfaceRequest::Run() { SDL_LOG_AUTO_TRACE(); SDL_LOG_DEBUG("Connection key is " << connection_key()); - WaitForHMIIsReady(); - - if (application_manager_.IsStopping()) { - SDL_LOG_WARN("The ApplicationManager is stopping!"); + if (!application_manager_.WaitForHmiIsReady()) { + SDL_LOG_WARN("Failed to wait for HMI readiness"); return; } 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 40302e51d56..f4e07d4b78f 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 @@ -89,6 +89,10 @@ void ResetGlobalPropertiesRequest::Run() { StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_TTS); } + if (reset_global_props_result.HasRCPropertiesReset()) { + StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_RC); + } + app->set_reset_global_properties_active(true); if (reset_global_props_result.HasUIPropertiesReset()) { @@ -110,6 +114,15 @@ void ResetGlobalPropertiesRequest::Run() { SendHMIRequest( hmi_apis::FunctionID::TTS_SetGlobalProperties, msg_params.get(), true); } + + if (reset_global_props_result.HasRCPropertiesReset()) { + smart_objects::SmartObjectSPtr msg_params = + MessageHelper::CreateRCResetGlobalPropertiesRequest( + reset_global_props_result, app); + + SendHMIRequest( + hmi_apis::FunctionID::RC_SetGlobalProperties, msg_params.get(), true); + } } void ResetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { 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 a6f980b9bad..b7cf0e15ac8 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 @@ -57,15 +57,7 @@ ScrollableMessageResponse::ScrollableMessageResponse( void ScrollableMessageResponse::Run() { SDL_LOG_AUTO_TRACE(); - mobile_apis::Result::eType result_code = - static_cast( - (*message_)[strings::msg_params][strings::result_code].asInt()); - ApplicationSharedPtr application = application_manager_.application( - (*message_)[strings::params][strings::connection_key].asInt()); - if ((mobile_apis::Result::REJECTED != result_code) && application) { - application->UnsubscribeFromSoftButtons( - (*message_)[strings::params][strings::function_id].asInt()); - } + application_manager_.UnsubscribeAppFromSoftButtons(message_); rpc_service_.SendMessageToMobile(message_); } 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 aa5e1077cab..2b0a36cb9d2 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 @@ -70,6 +70,7 @@ void SendHapticDataRequest::Run() { } if (app->is_navi() || app->mobile_projection_enabled()) { + msg_params[strings::app_id] = connection_key(); SendHMIRequest(hmi_apis::FunctionID::UI_SendHapticData, &msg_params, true); } else { SendResponse(false, 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 9f304781111..9eb4c827210 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 @@ -116,8 +116,8 @@ void SetAppIconRequest::Run() { msg_params[strings::sync_file_name] = smart_objects::SmartObject(smart_objects::SmartType_Map); - // For further use in on_event function - full_file_path_for_hmi_ = file_system::ConvertPathForURL(full_file_path); + // for further use in on_event function + full_file_path_for_hmi_ = full_file_path; msg_params[strings::sync_file_name][strings::value] = full_file_path_for_hmi_; 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 396763ff98f..bbce4d2bb35 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 @@ -151,6 +151,17 @@ void SetGlobalPropertiesRequest::Run() { return; } + if (!ValidateCustomKeys()) { + SDL_LOG_ERROR( + "Number of customizable keys exceeds the maximum number for this " + "layout"); + SendResponse( + false, + mobile_apis::Result::INVALID_DATA, + "customKeys exceeds the number of customizable keys in this Layout"); + return; + } + // if application waits for sending ttsGlobalProperties need to remove this // application from tts_global_properties_app_list_ application_manager_.RemoveAppFromTTSGlobalPropertiesList(connection_key()); @@ -642,7 +653,53 @@ void SetGlobalPropertiesRequest::PrepareUIRequestMenuAndKeyboardData( if (is_keyboard_props_present) { out_params[hmi_request::keyboard_properties] = msg_params[hmi_request::keyboard_properties]; - app->set_keyboard_props(msg_params[hmi_request::keyboard_properties]); + smart_objects::SmartObject cached_keyboard_props( + msg_params[hmi_request::keyboard_properties]); + + if (cached_keyboard_props.keyExists(hmi_request::auto_complete_list)) { + auto auto_complete_list = + cached_keyboard_props[hmi_request::auto_complete_list].asArray(); + if (auto_complete_list && auto_complete_list->empty()) { + cached_keyboard_props.erase(hmi_request::auto_complete_list); + } + } + + auto saved_keyboard_props = app->keyboard_props(); + if (!saved_keyboard_props) { + app->set_keyboard_props(cached_keyboard_props); + return; + } + + if (!msg_params[hmi_request::keyboard_properties].keyExists( + hmi_request::keyboard_layout) && + saved_keyboard_props->keyExists(hmi_request::keyboard_layout)) { + cached_keyboard_props[hmi_request::keyboard_layout] = + static_cast( + (*saved_keyboard_props)[hmi_request::keyboard_layout].asInt()); + } + + if (!msg_params[hmi_request::keyboard_properties].keyExists( + hmi_response::language) && + saved_keyboard_props->keyExists(hmi_response::language)) { + cached_keyboard_props[hmi_response::language] = + static_cast( + (*saved_keyboard_props)[hmi_response::language].asInt()); + } + + if (!msg_params[hmi_request::keyboard_properties].keyExists( + hmi_request::auto_complete_list) && + saved_keyboard_props->keyExists(hmi_request::auto_complete_list)) { + cached_keyboard_props[hmi_request::auto_complete_list] = + (*saved_keyboard_props)[hmi_request::auto_complete_list]; + } + + if (!msg_params[hmi_request::keyboard_properties].keyExists( + hmi_request::mask_input_characters) && + saved_keyboard_props->keyExists(hmi_request::mask_input_characters)) { + cached_keyboard_props[hmi_request::mask_input_characters] = + (*saved_keyboard_props)[hmi_request::mask_input_characters]; + } + app->set_keyboard_props(cached_keyboard_props); } } @@ -820,9 +877,130 @@ bool SetGlobalPropertiesRequest::IsWhiteSpaceExist() { } } } + + if (msg_params[strings::keyboard_properties].keyExists( + hmi_request::custom_keys)) { + const smart_objects::SmartArray* custom_keys_array = + msg_params[strings::keyboard_properties][hmi_request::custom_keys] + .asArray(); + + for (auto keys : (*custom_keys_array)) { + if (!CheckSyntax(keys.asCharArray())) { + SDL_LOG_ERROR( + "Invalid keyboard_properties " + "custom_keys syntax check failed"); + return true; + } + } + } } + return false; } +hmi_apis::Common_KeyboardLayout::eType +SetGlobalPropertiesRequest::GetKeyboardLayout() const { + SDL_LOG_AUTO_TRACE(); + + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + if (msg_params[strings::keyboard_properties].keyExists( + hmi_request::keyboard_layout)) { + return static_cast( + msg_params[strings::keyboard_properties][hmi_request::keyboard_layout] + .asInt()); + } + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + auto saved_keyboard_props = app->keyboard_props(); + if (saved_keyboard_props) { + if (saved_keyboard_props->keyExists(hmi_request::keyboard_layout)) { + return static_cast( + (*saved_keyboard_props)[hmi_request::keyboard_layout].asInt()); + } + } + + return hmi_apis::Common_KeyboardLayout::QWERTY; +} + +uint32_t SetGlobalPropertiesRequest::GetAllowedNumberOfConfigurableKeys() + const { + SDL_LOG_AUTO_TRACE(); + + ApplicationSharedPtr app = application_manager_.application(connection_key()); + auto display_capabilities = app->display_capabilities(); + if (!display_capabilities) { + SDL_LOG_WARN("Display capabilities are not available"); + return 0; + } + + auto* window_capabilities = + (*display_capabilities)[0][strings::window_capabilities].asArray(); + + if (!window_capabilities) { + SDL_LOG_WARN("Window capabilities are not available"); + return 0; + } + + if (!(*window_capabilities)[0].keyExists( + hmi_response::keyboard_capabilities)) { + SDL_LOG_WARN("Keyboard capabilities are not available"); + return 0; + } + + if (!(*window_capabilities)[0][hmi_response::keyboard_capabilities].keyExists( + hmi_response::supported_keyboards)) { + SDL_LOG_WARN("Data about supported keyboards is not available"); + return 0; + } + + auto supported_keyboards = + (*window_capabilities)[0][hmi_response::keyboard_capabilities] + [hmi_response::supported_keyboards] + .asArray(); + + const auto requested_layout = GetKeyboardLayout(); + for (auto keyboard : (*supported_keyboards)) { + if (requested_layout == + static_cast( + keyboard[hmi_request::keyboard_layout].asInt())) { + return keyboard[hmi_response::num_configurable_keys].asUInt(); + } + } + + return 0; +} + +bool SetGlobalPropertiesRequest::ValidateCustomKeys() const { + SDL_LOG_AUTO_TRACE(); + + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + if (!msg_params.keyExists(strings::keyboard_properties)) { + SDL_LOG_WARN("Keyboard properties are not available"); + return true; + } + + if (!msg_params[strings::keyboard_properties].keyExists( + hmi_request::custom_keys)) { + SDL_LOG_WARN("Customizable keys are not available"); + return true; + } + + auto custom_keys_array = + msg_params[strings::keyboard_properties][hmi_request::custom_keys] + .asArray(); + if (custom_keys_array) { + uint32_t requested_key_count = custom_keys_array->size(); + uint32_t allowed_key_count = GetAllowedNumberOfConfigurableKeys(); + + if (requested_key_count > allowed_key_count) { + 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/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 cf5d80ecc08..285118749a6 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 @@ -37,6 +37,7 @@ #include "application_manager/message_helper.h" #include "interfaces/HMI_API.h" #include "interfaces/MOBILE_API.h" +#include "smart_objects/enum_schema_item.h" namespace sdl_rpc_plugin { using namespace application_manager; @@ -76,7 +77,8 @@ void SetMediaClockRequest::Run() { return; } - if (isDataValid()) { + std::string info; + if (isDataValid(info)) { // copy entirely msg smart_objects::SmartObject msg_params = (*message_)[strings::msg_params]; msg_params[strings::app_id] = app->app_id(); @@ -85,7 +87,9 @@ void SetMediaClockRequest::Run() { SendHMIRequest( hmi_apis::FunctionID::UI_SetMediaClockTimer, &msg_params, true); } else { - SendResponse(false, mobile_apis::Result::INVALID_DATA); + SendResponse(false, + mobile_apis::Result::INVALID_DATA, + info.empty() ? NULL : info.c_str()); } } @@ -117,7 +121,7 @@ void SetMediaClockRequest::on_event(const event_engine::Event& event) { } } -bool SetMediaClockRequest::isDataValid() { +bool SetMediaClockRequest::isDataValid(std::string& info) { smart_objects::SmartObject msg_params = (*message_)[strings::msg_params]; mobile_apis::UpdateMode::eType update_mode = static_cast( @@ -126,7 +130,10 @@ bool SetMediaClockRequest::isDataValid() { if (update_mode == mobile_apis::UpdateMode::COUNTUP || update_mode == mobile_apis::UpdateMode::COUNTDOWN) { if (!msg_params.keyExists(strings::start_time)) { - SDL_LOG_INFO("Invalid data"); + info = + "Start time must be provided for \"COUNTUP\" and \"COUNTDOWN\" " + "update modes"; + SDL_LOG_INFO("Invalid data: " << info); return false; } @@ -151,7 +158,33 @@ bool SetMediaClockRequest::isDataValid() { (update_mode == mobile_apis::UpdateMode::COUNTDOWN)) || ((end_time_in_seconds < start_time_in_seconds) && (update_mode == mobile_apis::UpdateMode::COUNTUP))) { - SDL_LOG_INFO("Invalid data"); + std::string update_mode_name; + smart_objects::EnumConversionHelper< + mobile_apis::UpdateMode::eType>::EnumToString(update_mode, + &update_mode_name); + info = "Start time must be " + + std::string((update_mode == mobile_apis::UpdateMode::COUNTUP) + ? "before" + : "after") + + " the end time for update mode " + update_mode_name; + SDL_LOG_INFO("Invalid data: " << info); + return false; + } + } + } + + std::vector indicator_keys{strings::forward_seek_indicator, + strings::back_seek_indicator}; + for (auto& key : indicator_keys) { + if (msg_params.keyExists(key)) { + mobile_apis::SeekIndicatorType::eType seek_indicator_type = + static_cast( + msg_params[key][strings::type].asUInt()); + if (seek_indicator_type == mobile_apis::SeekIndicatorType::TRACK && + msg_params[key].keyExists(strings::seek_time)) { + info = + "The seekTime parameter is not applicable for indicator type TRACK"; + SDL_LOG_INFO("Invalid data: " << info); return false; } } 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 7d546079e88..a2362a74bcf 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 @@ -60,6 +60,8 @@ ShowConstantTBTResponse::~ShowConstantTBTResponse() {} void ShowConstantTBTResponse::Run() { SDL_LOG_AUTO_TRACE(); + application_manager_.UnsubscribeAppFromSoftButtons(message_); + rpc_service_.SendMessageToMobile(message_); } 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 6e8ad05a743..11cbdac14aa 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subscribe_way_points_request.cc @@ -31,6 +31,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/subscribe_way_points_request.h" + +#include "application_manager/app_service_manager.h" #include "application_manager/application_manager.h" #include "application_manager/message_helper.h" @@ -72,8 +74,8 @@ void SubscribeWayPointsRequest::Run() { return; } - if (application_manager_.IsAnyAppSubscribedForWayPoints()) { - application_manager_.SubscribeAppForWayPoints(app); + if (application_manager_.IsSubscribedToHMIWayPoints()) { + application_manager_.SubscribeAppForWayPoints(app, false); SendResponse(true, mobile_apis::Result::SUCCESS); return; } @@ -91,15 +93,20 @@ void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) { case hmi_apis::FunctionID::Navigation_SubscribeWayPoints: { SDL_LOG_INFO("Received Navigation_SubscribeWayPoints event"); EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); - const hmi_apis::Common_Result::eType result_code = + hmi_apis::Common_Result::eType result_code = static_cast( message[strings::params][hmi_response::code].asInt()); std::string response_info; GetInfo(message, response_info); - const bool result = PrepareResultForMobileResponse( + bool result = PrepareResultForMobileResponse( result_code, HmiInterfaces::HMI_INTERFACE_Navigation); if (result) { - application_manager_.SubscribeAppForWayPoints(app); + application_manager_.SubscribeAppForWayPoints(app, true); + } else if (application_manager_.GetAppServiceManager() + .FindWayPointsHandler() != nullptr) { + application_manager_.SubscribeAppForWayPoints(app, false); + result = true; + result_code = hmi_apis::Common_Result::WARNINGS; } SendResponse(result, MessageHelper::HMIToMobileResult(result_code), @@ -114,6 +121,23 @@ void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) { } } +void SubscribeWayPointsRequest::onTimeOut() { + SDL_LOG_AUTO_TRACE(); + if (application_manager_.GetAppServiceManager().FindWayPointsHandler() != + nullptr) { + ApplicationSharedPtr app = + application_manager_.application(connection_key()); + application_manager_.SubscribeAppForWayPoints(app, false); + SendResponse(true, + mobile_apis::Result::WARNINGS, + "HMI request timeout expired, waypoints are available through " + "NAVIGATION service"); + } else { + SendResponse( + false, mobile_apis::Result::GENERIC_ERROR, "Request timeout expired"); + } +} + bool SubscribeWayPointsRequest::Init() { hash_update_mode_ = HashUpdateMode::kDoHashUpdate; return true; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subtle_alert_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subtle_alert_request.cc index 327315b372f..1a54f7f106f 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subtle_alert_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/subtle_alert_request.cc @@ -206,20 +206,10 @@ bool SubtleAlertRequest::PrepareResponseParameters( bool result = PrepareResultForMobileResponse(ui_subtle_alert_info, tts_alert_info); - /* result=false if UI interface is ok and TTS interface = UNSUPPORTED_RESOURCE - * and sdl receive TTS.IsReady=true or SDL doesn't receive response for - * TTS.IsReady. - */ - if (result && ui_subtle_alert_info.is_ok && - tts_alert_info.is_unsupported_resource && - HmiInterfaces::STATE_NOT_AVAILABLE != tts_alert_info.interface_state) { - result = false; - } result_code = mobile_apis::Result::WARNINGS; if ((ui_subtle_alert_info.is_ok || ui_subtle_alert_info.is_not_used) && tts_alert_info.is_unsupported_resource && HmiInterfaces::STATE_AVAILABLE == tts_alert_info.interface_state) { - tts_response_info_ = "Unsupported phoneme type sent in a prompt"; info = app_mngr::commands::MergeInfos(ui_subtle_alert_info, ui_response_info_, tts_alert_info, @@ -244,7 +234,11 @@ bool SubtleAlertRequest::PrepareResponseParameters( tts_alert_info, tts_response_info_); // Mobile Alert request is successful when UI_SubtleAlert is successful - if (is_ui_subtle_alert_sent_ && !ui_subtle_alert_info.is_ok) { + bool has_unsupported_data = ui_subtle_alert_info.is_unsupported_resource && + HmiInterfaces::STATE_NOT_AVAILABLE != + ui_subtle_alert_info.interface_state; + if (is_ui_subtle_alert_sent_ && !ui_subtle_alert_info.is_ok && + !has_unsupported_data) { return false; } return result; 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 545a36def84..7aa6e2b40ad 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/unsubscribe_way_points_request.cc @@ -31,6 +31,8 @@ */ #include "sdl_rpc_plugin/commands/mobile/unsubscribe_way_points_request.h" + +#include "application_manager/app_service_manager.h" #include "application_manager/application_manager.h" #include "application_manager/message_helper.h" @@ -75,9 +77,10 @@ void UnsubscribeWayPointsRequest::Run() { std::set subscribed_apps = application_manager_.GetAppsSubscribedForWayPoints(); - if (subscribed_apps.size() > 1) { + if (subscribed_apps.size() > 1 || + !application_manager_.IsSubscribedToHMIWayPoints()) { // More than 1 subscribed app, don't send HMI unsubscribe request - application_manager_.UnsubscribeAppFromWayPoints(app); + application_manager_.UnsubscribeAppFromWayPoints(app, false); SendResponse(true, mobile_apis::Result::SUCCESS, NULL); return; } else { @@ -96,15 +99,20 @@ void UnsubscribeWayPointsRequest::on_event(const event_engine::Event& event) { case hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints: { SDL_LOG_INFO("Received Navigation_UnsubscribeWayPoints event"); EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_Navigation); - const hmi_apis::Common_Result::eType result_code = + hmi_apis::Common_Result::eType result_code = static_cast( message[strings::params][hmi_response::code].asInt()); std::string response_info; GetInfo(message, response_info); - const bool result = PrepareResultForMobileResponse( + bool result = PrepareResultForMobileResponse( result_code, HmiInterfaces::HMI_INTERFACE_Navigation); if (result) { - application_manager_.UnsubscribeAppFromWayPoints(app); + application_manager_.UnsubscribeAppFromWayPoints(app, true); + } else if (application_manager_.GetAppServiceManager() + .FindWayPointsHandler() != nullptr) { + application_manager_.UnsubscribeAppFromWayPoints(app, false); + result = true; + result_code = hmi_apis::Common_Result::WARNINGS; } SendResponse(result, MessageHelper::HMIToMobileResult(result_code), @@ -119,6 +127,23 @@ void UnsubscribeWayPointsRequest::on_event(const event_engine::Event& event) { } } +void UnsubscribeWayPointsRequest::onTimeOut() { + SDL_LOG_AUTO_TRACE(); + if (application_manager_.GetAppServiceManager().FindWayPointsHandler() != + nullptr) { + ApplicationSharedPtr app = + application_manager_.application(connection_key()); + application_manager_.UnsubscribeAppFromWayPoints(app, false); + SendResponse(true, + mobile_apis::Result::WARNINGS, + "HMI request timeout expired, waypoints are available through " + "NAVIGATION service"); + } else { + SendResponse( + false, mobile_apis::Result::GENERIC_ERROR, "Request timeout expired"); + } +} + bool UnsubscribeWayPointsRequest::Init() { hash_update_mode_ = HashUpdateMode::kDoHashUpdate; return true; diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/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 bedf91b45c5..bf2658128d2 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 @@ -59,6 +59,8 @@ UpdateTurnListResponse::~UpdateTurnListResponse() {} void UpdateTurnListResponse::Run() { SDL_LOG_AUTO_TRACE(); + application_manager_.UnsubscribeAppFromSoftButtons(message_); + rpc_service_.SendMessageToMobile(message_); } 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 570a4ce12e3..2727c89673b 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 @@ -173,6 +173,7 @@ #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/bc_on_app_capability_updated_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/navi_alert_maneuver_request.h" @@ -942,6 +943,10 @@ CommandCreator& HMICommandFactory::get_creator_factory( case hmi_apis::FunctionID::UI_OnSubtleAlertPressed: { return factory.GetCreator(); } + case hmi_apis::FunctionID::BasicCommunication_OnAppCapabilityUpdated: { + return factory + .GetCreator(); + } default: { return factory.GetCreator(); } } } 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 d2f1325c822..0a8c342448e 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 @@ -76,6 +76,7 @@ #include "sdl_rpc_plugin/commands/mobile/get_way_points_response.h" #include "sdl_rpc_plugin/commands/mobile/list_files_request.h" #include "sdl_rpc_plugin/commands/mobile/list_files_response.h" +#include "sdl_rpc_plugin/commands/mobile/on_app_capability_updated_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_app_interface_unregistered_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_audio_pass_thru_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_button_event_notification.h" @@ -96,6 +97,7 @@ #include "sdl_rpc_plugin/commands/mobile/on_update_file_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_update_sub_menu_notification.h" #include "sdl_rpc_plugin/commands/mobile/on_way_point_change_notification.h" +#include "sdl_rpc_plugin/commands/mobile/on_way_point_change_notification_from_mobile.h" #include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_request.h" #include "sdl_rpc_plugin/commands/mobile/perform_audio_pass_thru_response.h" #include "sdl_rpc_plugin/commands/mobile/perform_interaction_request.h" @@ -491,6 +493,14 @@ CommandCreator& MobileCommandFactory::get_notification_from_mobile_creator( case mobile_apis::FunctionID::OnHMIStatusID: { return factory.GetCreator(); } + case mobile_apis::FunctionID::OnWayPointChangeID: { + return factory + .GetCreator(); + } + case mobile_apis::FunctionID::OnAppCapabilityUpdatedID: { + return factory + .GetCreator(); + } default: {} } return factory.GetCreator(); @@ -543,10 +553,12 @@ bool MobileCommandFactory::IsAbleToProcess( const int32_t function_id, const application_manager::commands::Command::CommandSource message_source) const { + SDL_LOG_AUTO_TRACE(); auto id = static_cast(function_id); return get_command_creator(id, mobile_apis::messageType::INVALID_ENUM) .CanBeCreated() || - get_notification_creator(id).CanBeCreated(); + get_notification_creator(id).CanBeCreated() || + get_notification_from_mobile_creator(id).CanBeCreated(); } CommandSharedPtr MobileCommandFactory::CreateCommand( 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 4756c8b9a26..c5bc79f09da 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 @@ -131,14 +131,20 @@ void SDLRPCPlugin::RevertResumption(application_manager::Application& app) { pending_resumption_handler_->OnResumptionRevert(); if (application_manager_->IsAppSubscribedForWayPoints(app)) { - application_manager_->UnsubscribeAppFromWayPoints(app.app_id()); - if (!application_manager_->IsAnyAppSubscribedForWayPoints()) { + const auto subscribed_apps = + application_manager_->GetAppsSubscribedForWayPoints(); + const bool send_unsubscribe = + subscribed_apps.size() <= 1 && + application_manager_->IsSubscribedToHMIWayPoints(); + if (send_unsubscribe) { SDL_LOG_DEBUG("Send UnsubscribeWayPoints"); auto request = application_manager::MessageHelper::CreateUnsubscribeWayPointsRequest( application_manager_->GetNextHMICorrelationID()); application_manager_->GetRPCService().ManageHMICommand(request); } + application_manager_->UnsubscribeAppFromWayPoints(app.app_id(), + send_unsubscribe); } } diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_pending_resumption_handler.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_pending_resumption_handler.cc index 7aa6dd52731..af6c7f3c1d3 100644 --- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_pending_resumption_handler.cc +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/waypoints_pending_resumption_handler.cc @@ -86,7 +86,7 @@ void WayPointsPendingResumptionHandler::HandleResumptionSubscriptionRequest( SDL_LOG_DEBUG( "Subscription to waypoint already exist, no need to send " "request to HMI"); - application_manager_.SubscribeAppForWayPoints(app.app_id()); + application_manager_.SubscribeAppForWayPoints(app.app_id(), false); return; } @@ -154,10 +154,10 @@ void WayPointsPendingResumptionHandler::on_event( } const smart_objects::SmartObject& response = event.smart_object(); - const uint32_t corr_id = event.smart_object_correlation_id(); SDL_LOG_TRACE("Received event with function id: " - << event.id() << " and correlation id: " << corr_id); + << event.id() << " and correlation id: " + << event.smart_object_correlation_id()); auto current_pending = pending_requests_.front(); pending_requests_.pop_front(); @@ -170,7 +170,7 @@ void WayPointsPendingResumptionHandler::on_event( if (resumption::IsResponseSuccessful(response)) { SDL_LOG_DEBUG("Resumption of waypoints is successful"); - application_manager_.SubscribeAppForWayPoints(app); + application_manager_.SubscribeAppForWayPoints(app, true); } ProcessNextPendingResumption(); } @@ -195,7 +195,7 @@ void WayPointsPendingResumptionHandler::ProcessNextPendingResumption() { auto pending_copy = pending; pending_requests_.pop_front(); auto app = application_manager_.application(pending_copy.app_id_); - application_manager_.SubscribeAppForWayPoints(app); + application_manager_.SubscribeAppForWayPoints(app, false); RaiseFakeSuccessfulResponse(pending_copy.corr_id_); ProcessNextPendingResumption(); } 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 b21ab9dca86..b5bb1393778 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 @@ -24,6 +24,7 @@ file(GLOB SOURCES set(LIBRARIES sdl_rpc_plugin_static + Resumption gmock ) diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/bc_on_app_capability_updated_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/bc_on_app_capability_updated_notification_test.cc new file mode 100644 index 00000000000..2d875a2680f --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/hmi/bc_on_app_capability_updated_notification_test.cc @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2020, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "hmi/bc_on_app_capability_updated_notification.h" + +#include "application_manager/commands/commands_test.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 hmi_commands_test { +namespace bc_on_app_capability_updated_notification_test { + +using sdl_rpc_plugin::commands::BCOnAppCapabilityUpdatedNotification; +using ::testing::_; + +typedef std::shared_ptr + BCOnAppCapabilityUpdatedNotificationPtr; + +namespace strings = application_manager::strings; +namespace { +const uint32_t kConnectionKey = 1u; +} // namespace + +MATCHER_P(CheckAppCapability, app_capability, "") { + return app_capability == (*arg)[strings::msg_params][strings::app_capability]; +} + +class BCOnAppCapabilityUpdatedNotificationTest + : public CommandsTest { + protected: + void SetUp() OVERRIDE { + message_ = CreateMessage(); + (*message_)[strings::params][strings::connection_key] = kConnectionKey; + command_ = CreateCommand(message_); + mock_app_ = CreateMockApp(); + } + + BCOnAppCapabilityUpdatedNotificationPtr command_; + MockAppPtr mock_app_; + MessageSharedPtr message_; +}; + +TEST_F(BCOnAppCapabilityUpdatedNotificationTest, Run_SendMessageToHMI_SUCCESS) { + smart_objects::SmartObject app_capability = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + app_capability[strings::app_capability_type] = + mobile_apis::AppCapabilityType::VIDEO_STREAMING; + app_capability[strings::video_streaming_capability] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + FillVideoStreamingCapability( + app_capability[strings::video_streaming_capability]); + + (*message_)[strings::msg_params][strings::app_capability] = app_capability; + + ASSERT_TRUE(command_->Init()); + + EXPECT_CALL(mock_rpc_service_, + SendMessageToHMI(CheckAppCapability(app_capability))); + command_->Run(); +} + +} // namespace bc_on_app_capability_updated_notification_test +} // 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/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 8cdce4fa749..3e018498075 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 @@ -68,6 +68,7 @@ typedef NiceMock< namespace { const uint32_t kConnectionKey = 2u; const std::string ccpu_version("4.1.3.B_EB355B"); +const std::string kHardwareVersion("1.1.1.1"); const std::string wers_country_code("WAEGB"); const std::string lang_code("EN-US"); } // namespace @@ -82,14 +83,36 @@ class GetSystemInfoResponseTest (*command_msg)[strings::msg_params]["ccpu_version"] = ccpu_version; (*command_msg)[strings::msg_params]["wersCountryCode"] = wers_country_code; (*command_msg)[strings::msg_params]["language"] = lang_code; - return command_msg; } + void SetHardwareVersionFromPT() { + const std::string hardware_version_from_pt = "1.1.1.0"; + ON_CALL(mock_policy_handler_, GetHardwareVersionFromPT()) + .WillByDefault(Return(hardware_version_from_pt)); + EXPECT_CALL(mock_hmi_capabilities_, + set_hardware_version(hardware_version_from_pt)); + } + SmartObject capabilities_; }; -TEST_F(GetSystemInfoResponseTest, GetSystemInfo_SUCCESS) { +TEST_F(GetSystemInfoResponseTest, GetSystemInfo_UNSUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); + (*command_msg)[strings::params][hmi_response::code] = + hmi_apis::Common_Result::WRONG_LANGUAGE; + (*command_msg)[strings::msg_params][hmi_response::capabilities] = + (capabilities_); + + ResponseFromHMIPtr command(CreateCommand(command_msg)); + + EXPECT_CALL(mock_hmi_capabilities_, UpdateCachedCapabilities()); + EXPECT_CALL(mock_policy_handler_, SetPreloadedPtFlag(false)); + + command->Run(); +} + +TEST_F(GetSystemInfoResponseTest, GetSystemInfo_UpdateCapabilities_Called) { MessageSharedPtr command_msg = CreateCommandMsg(); (*command_msg)[strings::params][hmi_response::code] = hmi_apis::Common_Result::SUCCESS; @@ -98,28 +121,35 @@ TEST_F(GetSystemInfoResponseTest, GetSystemInfo_SUCCESS) { ResponseFromHMIPtr command(CreateCommand(command_msg)); - EXPECT_CALL(mock_policy_handler_, - OnGetSystemInfo(ccpu_version, wers_country_code, lang_code)); + EXPECT_CALL(mock_hmi_capabilities_, OnSoftwareVersionReceived(ccpu_version)); + ASSERT_TRUE(command->Init()); command->Run(); } -TEST_F(GetSystemInfoResponseTest, GetSystemInfo_UNSUCCESS) { +TEST_F(GetSystemInfoResponseTest, + GetSystemInfo_SaveHardwareVersionToHMICapabilitiesIfPresentInResponse) { MessageSharedPtr command_msg = CreateCommandMsg(); (*command_msg)[strings::params][hmi_response::code] = - hmi_apis::Common_Result::WRONG_LANGUAGE; + hmi_apis::Common_Result::SUCCESS; (*command_msg)[strings::msg_params][hmi_response::capabilities] = (capabilities_); + (*command_msg)[strings::msg_params][strings::system_hardware_version] = + kHardwareVersion; ResponseFromHMIPtr command(CreateCommand(command_msg)); - EXPECT_CALL(mock_hmi_capabilities_, UpdateCachedCapabilities()); - EXPECT_CALL(mock_policy_handler_, SetPreloadedPtFlag(false)); + SetHardwareVersionFromPT(); + EXPECT_CALL(mock_policy_handler_, OnHardwareVersionReceived(_)); + EXPECT_CALL(mock_hmi_capabilities_, set_hardware_version(kHardwareVersion)); + ASSERT_TRUE(command->Init()); command->Run(); } -TEST_F(GetSystemInfoResponseTest, GetSystemInfo_UpdateCapabilities_Called) { +TEST_F( + GetSystemInfoResponseTest, + GetSystemInfo_DontSaveHardwareVersionToHMICapabilitiesIfAbsentInResponse) { MessageSharedPtr command_msg = CreateCommandMsg(); (*command_msg)[strings::params][hmi_response::code] = hmi_apis::Common_Result::SUCCESS; @@ -128,7 +158,10 @@ TEST_F(GetSystemInfoResponseTest, GetSystemInfo_UpdateCapabilities_Called) { ResponseFromHMIPtr command(CreateCommand(command_msg)); - EXPECT_CALL(mock_hmi_capabilities_, OnSoftwareVersionReceived(ccpu_version)); + SetHardwareVersionFromPT(); + EXPECT_CALL(mock_policy_handler_, OnHardwareVersionReceived(_)).Times(0); + EXPECT_CALL(mock_hmi_capabilities_, set_hardware_version(kHardwareVersion)) + .Times(0); ASSERT_TRUE(command->Init()); command->Run(); 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 400481f5064..5487da51a30 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 @@ -92,6 +92,7 @@ #include "utils/signals.h" #include "application_manager/hmi_capabilities_impl.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_event_dispatcher.h" @@ -106,6 +107,8 @@ #include "connection_handler/mock_connection_handler.h" #include "connection_handler/mock_connection_handler_settings.h" #include "protocol_handler/mock_session_observer.h" +#include "resumption/last_state_wrapper_impl.h" +#include "resumption/mock_last_state.h" #include "smart_objects/smart_object.h" #include "test/application_manager/mock_application_manager_settings.h" #include "transport_manager/mock_transport_manager.h" @@ -127,6 +130,7 @@ using ::test::components::application_manager_test::MockApplication; using ::test::components::application_manager_test::MockApplicationManager; using ::test::components::application_manager_test:: MockApplicationManagerSettings; +using ::test::components::application_manager_test::MockAppServiceManager; using ::test::components::event_engine_test::MockEventDispatcher; using ::testing::_; using ::testing::InSequence; @@ -216,7 +220,11 @@ class HMICommandsNotificationsTest HMICommandsNotificationsTest() : applications_lock_(std::make_shared()) , applications_(application_set_, applications_lock_) - , app_ptr_(NULL) {} + , app_ptr_(NULL) + , mock_last_state_(std::make_shared()) + , last_state_wrapper_(std::make_shared( + mock_last_state_)) + , mock_app_service_manager_(app_mngr_, last_state_wrapper_) {} ~HMICommandsNotificationsTest() { // Fix DataAccessor release and WinQt crash @@ -244,6 +252,9 @@ class HMICommandsNotificationsTest MockConnectionHandler mock_connection_handler_; MockSessionObserver mock_session_observer_; + std::shared_ptr mock_last_state_; + resumption::LastStateWrapperPtr last_state_wrapper_; + MockAppServiceManager mock_app_service_manager_; void InitCommand(const uint32_t& default_timeout) OVERRIDE { app_ = ConfigureApp(&app_ptr_, kAppId_, NOT_MEDIA, NOT_NAVI, NOT_VC); @@ -256,6 +267,8 @@ class HMICommandsNotificationsTest 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(app_mngr_, GetAppServiceManager()) + .WillByDefault(ReturnRef(mock_app_service_manager_)); ON_CALL(app_mngr_, connection_handler()) .WillByDefault(ReturnRef(mock_connection_handler_)); } @@ -428,6 +441,8 @@ TEST_F(HMICommandsNotificationsTest, MessageSharedPtr message = CreateMessage(); std::shared_ptr command = CreateCommand(message); + EXPECT_CALL(mock_app_service_manager_, FindWayPointsHandler()) + .WillOnce(Return(nullptr)); EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, Command::CommandSource::SOURCE_SDL)); command->Run(); 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 index ae2a544cc94..1316952a927 100644 --- 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 @@ -33,6 +33,8 @@ #include "hmi/on_bc_system_capability_updated_notification_from_hmi.h" #include "application_manager/commands/commands_test.h" +#include "sdl_rpc_plugin/extensions/system_capability_app_extension.h" + #include "gtest/gtest.h" namespace test { @@ -47,8 +49,10 @@ using ::testing::Return; typedef std::shared_ptr OnBCSystemCapabilityUpdatedNotificationFromHMIPtr; +typedef mobile_apis::SystemCapabilityType::eType SystemCapabilityType; namespace strings = application_manager::strings; + namespace { const uint32_t kAppId = 1u; } // namespace @@ -61,11 +65,30 @@ MATCHER(CheckMessageToMobile, "") { (*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; - } + const bool is_connection_key_correct = [](arg_type arg) { + if ((*arg)[strings::msg_params].keyExists(strings::connection_key)) { + return (*arg)[strings::params][strings::connection_key] == kAppId; + } + return false; + }; + + return is_function_id_matched && app_id_exist && is_connection_key_correct; +} + +MATCHER(CheckMessageToMobileWithoutAppId, "") { + 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); + const bool is_connection_key_correct = [](arg_type arg) { + if ((*arg)[strings::msg_params].keyExists(strings::connection_key)) { + return (*arg)[strings::params][strings::connection_key] == kAppId; + } + return false; + }; return is_function_id_matched && !app_id_exist && is_connection_key_correct; } @@ -73,6 +96,27 @@ MATCHER_P(CheckDisplayCapabilitiesNotChanged, display_capability, "") { return display_capability == arg; } +MATCHER_P2(CheckVideoStreamingCapability, + system_capability_type, + video_streaming_capability, + "") { + const mobile_apis::SystemCapabilityType::eType received_sys_cap_type = + static_cast( + (*arg)[strings::msg_params][strings::system_capability] + [strings::system_capability_type] + .asInt()); + + const bool system_capability_type_matched = + received_sys_cap_type == system_capability_type; + + const bool video_capability_matched = + video_streaming_capability == + (*arg)[strings::msg_params][strings::system_capability] + [strings::video_streaming_capability]; + + return system_capability_type_matched && video_capability_matched; +} + class OnBCSystemCapabilityUpdatedNotificationFromHMITest : public CommandsTest { protected: @@ -105,7 +149,7 @@ TEST_F( EXPECT_CALL( mock_rpc_service_, ManageMobileCommand( - CheckMessageToMobile(), + CheckMessageToMobileWithoutAppId(), ::application_manager::commands::Command::CommandSource::SOURCE_SDL)) .WillOnce(Return(true)); @@ -130,7 +174,7 @@ TEST_F(OnBCSystemCapabilityUpdatedNotificationFromHMITest, TEST_F( OnBCSystemCapabilityUpdatedNotificationFromHMITest, - Run_AppRegisteredWithPresentedAppIdInMessage_SetDisplayCapabilitiesToApp_SendMessageToMobile) { + Run_AppRegisteredWithPresentedAppIdInMessage_SetDisplayCapabilitiesToAppAndAppIdIsErasedFromMessage_SendMessageToMobile) { (*message_)[am::strings::msg_params][strings::system_capability] [am::strings::system_capability_type] = mobile_apis::SystemCapabilityType::DISPLAYS; @@ -147,7 +191,7 @@ TEST_F( EXPECT_CALL( mock_rpc_service_, ManageMobileCommand( - CheckMessageToMobile(), + CheckMessageToMobileWithoutAppId(), ::application_manager::commands::Command::CommandSource::SOURCE_SDL)) .WillOnce(Return(true)); @@ -155,6 +199,149 @@ TEST_F( command_->Run(); } +TEST_F( + OnBCSystemCapabilityUpdatedNotificationFromHMITest, + Run_SysCapTypeVideoStreaming_CapabilityIsAbsent_DoesntSetInHMICapabilities) { + smart_objects::SmartObject system_capability = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + system_capability[strings::system_capability_type] = + mobile_apis::SystemCapabilityType::VIDEO_STREAMING; + + ASSERT_TRUE(command_->Init()); + EXPECT_CALL(mock_hmi_capabilities_, set_video_streaming_capability(_)) + .Times(0); + command_->Run(); +} + +TEST_F(OnBCSystemCapabilityUpdatedNotificationFromHMITest, + Run_VideoStreamingCapability_AppIdIsAbsent_NotificationIgnored) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::VIDEO_STREAMING; + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F(OnBCSystemCapabilityUpdatedNotificationFromHMITest, + Run_VideoStreamingCapability_AppNotRegistered_NotificationIgnored) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::VIDEO_STREAMING; + (*message_)[am::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_VideoStreamingCapability_AppNotSubsribed_NotificationIgnored) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::VIDEO_STREAMING; + (*message_)[am::strings::msg_params][strings::app_id] = kAppId; + + sdl_rpc_plugin::SDLRPCPlugin sdl_rpc_plugin; + + // By default system capability extension is not subsribed to the + // VIDEO_STREAMING + auto system_capability_app_extension = + std::make_shared( + sdl_rpc_plugin, *mock_app_); + + ON_CALL(*mock_app_, + QueryInterface(sdl_rpc_plugin::SystemCapabilityAppExtension:: + SystemCapabilityAppExtensionUID)) + .WillByDefault(Return(system_capability_app_extension)); + ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(mock_app_)); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F( + OnBCSystemCapabilityUpdatedNotificationFromHMITest, + Run_VideoStreamingCapability_AppIsSubsribed_VideoCapabilityIsAbsent_NotificationIgnored) { + const mobile_apis::SystemCapabilityType::eType system_capability_type = + mobile_apis::SystemCapabilityType::VIDEO_STREAMING; + + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = system_capability_type; + (*message_)[am::strings::msg_params][strings::app_id] = kAppId; + + 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(system_capability_type); + + ON_CALL(*mock_app_, + QueryInterface(sdl_rpc_plugin::SystemCapabilityAppExtension:: + SystemCapabilityAppExtensionUID)) + .WillByDefault(Return(system_capability_app_extension)); + ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(mock_app_)); + + EXPECT_CALL(mock_rpc_service_, ManageMobileCommand(_, _)).Times(0); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F( + OnBCSystemCapabilityUpdatedNotificationFromHMITest, + Run_VideoStreamingCapability_AppIsSubsribed_VideoCapabilityExists_NotificationForwarded) { + const mobile_apis::SystemCapabilityType::eType system_capability_type = + mobile_apis::SystemCapabilityType::VIDEO_STREAMING; + + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = system_capability_type; + (*message_)[am::strings::msg_params][strings::app_id] = kAppId; + + (*message_)[am::strings::msg_params][strings::system_capability] + [strings::video_streaming_capability] = + new smart_objects::SmartObject( + smart_objects::SmartType::SmartType_Map); + + auto& video_streaming_capability = + (*message_)[am::strings::msg_params][strings::system_capability] + [strings::video_streaming_capability]; + + FillVideoStreamingCapability(video_streaming_capability); + + 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(system_capability_type); + + ON_CALL(*mock_app_, + QueryInterface(sdl_rpc_plugin::SystemCapabilityAppExtension:: + SystemCapabilityAppExtensionUID)) + .WillByDefault(Return(system_capability_app_extension)); + ON_CALL(app_mngr_, application(kAppId)).WillByDefault(Return(mock_app_)); + + EXPECT_CALL(mock_rpc_service_, + ManageMobileCommand( + CheckVideoStreamingCapability(system_capability_type, + video_streaming_capability), + _)); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + } // namespace on_bc_system_capability_updated_notification_from_hmi } // namespace hmi_commands_test } // namespace commands_test 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 cf701caf51a..a1661dc247c 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 @@ -344,6 +344,7 @@ TEST_F(UIGetCapabilitiesResponseTest, SetVideoStreamingCapability_SUCCESS) { video_streaming_capability[strings::pixel_per_inch] = 117.f; video_streaming_capability[strings::scale] = 1.f; + video_streaming_capability[strings::preferred_fps] = 30; ResponseFromHMIPtr command( CreateCommand(command_msg)); 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 31c03a7ed55..9760462d052 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 @@ -92,10 +92,6 @@ class UpdateDeviceListRequestTest TEST_F(UpdateDeviceListRequestTest, RUN_LaunchHMIReturnsFalse) { MessageSharedPtr command_msg = CreateCommandMsg(); - EXPECT_CALL(app_mngr_, event_dispatcher()) - .WillOnce(ReturnRef(mock_event_dispatcher_)); - EXPECT_CALL(mock_event_dispatcher_, remove_observer(_)); - UpdateDeviceListRequestPtr command( CreateCommand(command_msg)); @@ -103,7 +99,7 @@ TEST_F(UpdateDeviceListRequestTest, RUN_LaunchHMIReturnsFalse) { EXPECT_CALL(settings_, launch_hmi()).WillOnce(Return(false)); - EXPECT_CALL(app_mngr_, IsHMICooperating()).Times(0); + EXPECT_CALL(app_mngr_, WaitForHmiIsReady()).Times(0); EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(command_msg)); command->Run(); @@ -114,13 +110,9 @@ TEST_F(UpdateDeviceListRequestTest, RUN_LaunchHMIReturnsFalse) { CommandImpl::protocol_version_); } -TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsTrue_SUCCESSS) { +TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsTrue_SUCCESS) { MessageSharedPtr command_msg = CreateCommandMsg(); - EXPECT_CALL(app_mngr_, event_dispatcher()) - .WillOnce(ReturnRef(mock_event_dispatcher_)); - EXPECT_CALL(mock_event_dispatcher_, remove_observer(_)); - UpdateDeviceListRequestPtr command( CreateCommand(command_msg)); @@ -128,7 +120,7 @@ TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsTrue_SUCCESSS) { EXPECT_CALL(settings_, launch_hmi()).WillOnce(Return(true)); - EXPECT_CALL(app_mngr_, IsHMICooperating()).WillOnce(Return(true)); + EXPECT_CALL(app_mngr_, WaitForHmiIsReady()).WillOnce(Return(true)); EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(command_msg)); command->Run(); @@ -139,29 +131,20 @@ TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsTrue_SUCCESSS) { CommandImpl::protocol_version_); } -TEST_F(UpdateDeviceListRequestTest, OnEvent_WrongEventId_UNSUCCESS) { - Event event(Event::EventID::INVALID_ENUM); - - EXPECT_CALL(app_mngr_, event_dispatcher()) - .WillOnce(ReturnRef(mock_event_dispatcher_)); - EXPECT_CALL(mock_event_dispatcher_, remove_observer(_)); - - UpdateDeviceListRequestPtr command(CreateCommand()); +TEST_F(UpdateDeviceListRequestTest, RUN_HMICooperatingReturnsFalse_UNSUCCESS) { + MessageSharedPtr command_msg = CreateCommandMsg(); - command->on_event(event); -} + UpdateDeviceListRequestPtr command( + CreateCommand(command_msg)); -TEST_F(UpdateDeviceListRequestTest, OnEvent_SUCCESS) { - Event event(Event::EventID::BasicCommunication_OnReady); + EXPECT_CALL(app_mngr_, get_settings()).WillOnce(ReturnRef(settings_)); - EXPECT_CALL(app_mngr_, event_dispatcher()) - .WillOnce(ReturnRef(mock_event_dispatcher_)); - EXPECT_CALL(mock_event_dispatcher_, remove_observer(_, _)); - EXPECT_CALL(mock_event_dispatcher_, remove_observer(_)); + EXPECT_CALL(settings_, launch_hmi()).WillOnce(Return(true)); - UpdateDeviceListRequestPtr command(CreateCommand()); + EXPECT_CALL(app_mngr_, WaitForHmiIsReady()).WillOnce(Return(false)); + EXPECT_CALL(mock_rpc_service_, SendMessageToHMI(_)).Times(0); - command->on_event(event); + command->Run(); } } // namespace update_device_list_request 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 aa199bd112b..93ae813535c 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 @@ -373,26 +373,27 @@ TEST_F(AddCommandRequestTest, Run_CommandIDAlreadyExists_EXPECT_INVALID_ID) { request_ptr->Run(); } -TEST_F(AddCommandRequestTest, - Run_CommandNameAlreadyExists_EXPECT_DUPLICATE_NAME) { +TEST_F(AddCommandRequestTest, Run_CommandNameAlreadyExists_EXPECT_Forwarded) { CreateBasicParamsUIRequest(); - SmartObject& msg_params = (*msg_)[strings::msg_params]; - msg_params[menu_params][hmi_request::parent_id] = kFirstParentId; - SmartObject& image = msg_params[cmd_icon]; + (*msg_)[msg_params][menu_name] = kMenuName; + SmartObject& image = (*msg_)[msg_params][cmd_icon]; EXPECT_CALL(mock_message_helper_, VerifyImage(image, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(*mock_app_, FindCommand(kCmdId)).WillOnce(Return(smart_obj_)); + EXPECT_CALL(*mock_app_, AddCommand(_, (*msg_)[msg_params])); + SmartObject first_command = SmartObject(SmartType_Map); SmartObject second_command = SmartObject(SmartType_Map); - const am::CommandsMap commands_map = + am::CommandsMap commands_map = CreateCommandsMap(first_command, second_command); EXPECT_CALL(*mock_app_, commands_map()) .WillRepeatedly(Return(DataAccessor( commands_map, lock_ptr_))); - EXPECT_CALL(mock_rpc_service_, - ManageMobileCommand( - MobileResultCodeIs(mobile_apis::Result::DUPLICATE_NAME), _)); + EXPECT_CALL( + mock_rpc_service_, + ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::UI_AddCommand), _)) + .WillOnce(Return(true)); std::shared_ptr request_ptr = CreateCommand(msg_); request_ptr->Run(); diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_app_capability_updated_notification_test.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_app_capability_updated_notification_test.cc new file mode 100644 index 00000000000..41e734137b5 --- /dev/null +++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/test/commands/mobile/on_app_capability_updated_notification_test.cc @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2020, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "mobile/on_app_capability_updated_notification.h" + +#include "application_manager/commands/commands_test.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_app_capability_updated_notification_test { + +using sdl_rpc_plugin::commands::mobile::OnAppCapabilityUpdatedNotification; +using ::testing::_; + +typedef std::shared_ptr + OnAppCapabilityUpdatedNotificationPtr; + +namespace strings = application_manager::strings; +namespace { +const uint32_t kConnectionKey = 1u; +const uint32_t kAppId = 2u; +} // namespace + +MATCHER_P(CheckAppCapability, app_capability, "") { + return app_capability == (*arg)[strings::msg_params][strings::app_capability]; +} + +class OnAppCapabilityUpdatedNotificationTest + : public CommandsTest { + protected: + void SetUp() OVERRIDE { + message_ = CreateMessage(); + (*message_)[strings::params][strings::connection_key] = kConnectionKey; + command_ = CreateCommand(message_); + mock_app_ = CreateMockApp(); + } + + OnAppCapabilityUpdatedNotificationPtr command_; + MockAppPtr mock_app_; + MessageSharedPtr message_; +}; + +TEST_F(OnAppCapabilityUpdatedNotificationTest, Run_ManageHMICommand_SUCCESS) { + smart_objects::SmartObject app_capability = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + app_capability[strings::app_capability_type] = + mobile_apis::AppCapabilityType::VIDEO_STREAMING; + app_capability[strings::video_streaming_capability] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + FillVideoStreamingCapability( + app_capability[strings::video_streaming_capability]); + + (*message_)[strings::msg_params][strings::app_capability] = app_capability; + + ASSERT_TRUE(command_->Init()); + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kAppId)); + + EXPECT_CALL(mock_rpc_service_, + ManageHMICommand(CheckAppCapability(app_capability), + app_mngr::commands::Command::SOURCE_SDL_TO_HMI)); + command_->Run(); +} + +} // namespace on_app_capability_updated_notification_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/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 index 7e7b16aa89c..32a13f402ca 100644 --- 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 @@ -63,6 +63,12 @@ MATCHER_P(CheckDisplayCapabilities, display_capabilities, "") { [strings::display_capabilities]; } +MATCHER_P(CheckVideoStreamCapability, video_streaming_capability, "") { + return video_streaming_capability == + (*arg)[strings::msg_params][strings::system_capability] + [strings::video_streaming_capability]; +} + class OnSystemCapabilityUpdatedNotificationTest : public CommandsTest { protected: @@ -233,6 +239,43 @@ TEST_F( command_->Run(); } +TEST_F(OnSystemCapabilityUpdatedNotificationTest, + Run_VideoSteamingCapability_AppIdIsAbsent_SendMessageToMobile) { + (*message_)[am::strings::msg_params][strings::system_capability] + [am::strings::system_capability_type] = + mobile_apis::SystemCapabilityType::VIDEO_STREAMING; + + EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(message_, false)); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + +TEST_F(OnSystemCapabilityUpdatedNotificationTest, + Run_VideoSteamingCapability_AppIdExistsInMessage_SendMessageToMobile) { + (*message_)[strings::msg_params][strings::system_capability] + [strings::system_capability_type] = + mobile_apis::SystemCapabilityType::VIDEO_STREAMING; + (*message_)[strings::msg_params][strings::app_id] = kAppId; + (*message_)[strings::msg_params][strings::system_capability] + [strings::video_streaming_capability] = + new smart_objects::SmartObject(smart_objects::SmartType_Map); + + auto& video_streaming_capability = + (*message_)[strings::msg_params][strings::system_capability] + [strings::video_streaming_capability]; + + FillVideoStreamingCapability(video_streaming_capability); + + EXPECT_CALL( + mock_rpc_service_, + SendMessageToMobile( + CheckVideoStreamCapability(video_streaming_capability), false)); + + ASSERT_TRUE(command_->Init()); + command_->Run(); +} + } // namespace on_system_capability_updated_notification } // namespace mobile_commands_test } // namespace commands_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 ec401ae2a8e..dc6f07f5254 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 @@ -139,7 +139,6 @@ TEST_F(OnWayPointChangeNotificationTest, .WillOnce(Return(apps_subscribed_for_way_points)); EXPECT_CALL(mock_rpc_service_, SendMessageToMobile(CheckMessageData(kApp1Id), _)); - EXPECT_CALL(app_mngr_, SaveWayPointsMessage(message_)); command_->Run(); } 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 fab648fc951..4572a6d9070 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 @@ -198,7 +198,7 @@ class RegisterAppInterfaceRequestTest void InitGetters() { ON_CALL(app_mngr_, GetCorrectMobileIDFromMessage(msg_)) .WillByDefault(Return(kAppId1)); - ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(true)); + ON_CALL(app_mngr_, WaitForHmiIsReady()).WillByDefault(Return(true)); ON_CALL(app_mngr_, resume_controller()) .WillByDefault(ReturnRef(mock_resume_crt_)); ON_CALL(app_mngr_, connection_handler()) @@ -416,11 +416,7 @@ TEST_F(RegisterAppInterfaceRequestTest, DefaultTimeout_CheckIfZero_SUCCESS) { TEST_F(RegisterAppInterfaceRequestTest, Run_MinimalData_SUCCESS) { InitBasicMessage(); (*msg_)[am::strings::msg_params][am::strings::hash_id] = kAppId1; - 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_, WaitForHmiIsReady()).WillOnce(Return(true)); EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false)); ON_CALL(mock_connection_handler_, @@ -504,11 +500,7 @@ TEST_F(RegisterAppInterfaceRequestTest, Run_HmiInterfacesStateAvailable_SUCCESS) { InitBasicMessage(); - EXPECT_CALL(app_mngr_, IsStopping()) - .WillOnce(Return(false)) - .WillOnce(Return(true)) - .WillOnce(Return(false)); - ON_CALL(app_mngr_, IsHMICooperating()).WillByDefault(Return(false)); + ON_CALL(app_mngr_, WaitForHmiIsReady()).WillByDefault(Return(true)); EXPECT_CALL(app_mngr_, IsApplicationForbidden(_, _)).WillOnce(Return(false)); ON_CALL(mock_connection_handler_, @@ -808,11 +800,8 @@ TEST_F(RegisterAppInterfaceRequestTest, 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)); + + ON_CALL(app_mngr_, WaitForHmiIsReady()).WillByDefault(Return(true)); EXPECT_CALL(app_mngr_, IsApplicationForbidden(kConnectionKey2, kAppId1)) .WillOnce(Return(false)); 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 9b72d41f7e1..4272005fbab 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 @@ -397,6 +397,29 @@ class SetGlobalPropertiesRequestTest ui_result, tts_result, rc_result, false); } + void AddCustomizableKeys(MessageSharedPtr msg) { + SmartObject customizable_keys(smart_objects::SmartType_Array); + customizable_keys[0] = "%"; + customizable_keys[1] = "@"; + customizable_keys[2] = "&"; + (*msg)[am::strings::msg_params][am::strings::keyboard_properties] + [am::hmi_request::custom_keys] = customizable_keys; + } + + std::shared_ptr GetCapabilitiesForConfigurableKeyboard( + hmi_apis::Common_KeyboardLayout::eType layout, int num_allowed_keys) { + auto display_capabilities = + std::make_shared(smart_objects::SmartType_Map); + auto& supported_keyboards = + (*display_capabilities)[0][am::strings::window_capabilities][0] + [am::hmi_response::keyboard_capabilities] + [am::hmi_response::supported_keyboards]; + supported_keyboards[0][am::hmi_request::keyboard_layout] = layout; + supported_keyboards[0][am::hmi_response::num_configurable_keys] = + num_allowed_keys; + return display_capabilities; + } + std::shared_ptr lock_ptr_; MockAppPtr mock_app_; std::shared_ptr @@ -1262,6 +1285,371 @@ TEST_F(SetGlobalPropertiesRequestTest, command->Run(); } +TEST_F(SetGlobalPropertiesRequestTest, + Run_InvalidCustomizableKeys_INVALID_DATA) { + MessageSharedPtr msg = CreateMsgParams(); + SmartObject customizable_keys(smart_objects::SmartType_Array); + customizable_keys[0] = "%"; + customizable_keys[1] = "\\n"; + customizable_keys[2] = " "; + (*msg)[am::strings::msg_params][am::strings::keyboard_properties] + [am::hmi_request::custom_keys] = customizable_keys; + + std::shared_ptr command( + CreateCommand(msg)); + + ExpectInvalidData(); + + command->Run(); +} + +TEST_F( + SetGlobalPropertiesRequestTest, + Run_DisallowedNumberOfCustomizableKeysAndLayoutFromRequest_INVALID_DATA) { + MessageSharedPtr msg = CreateMsgParams(); + AddCustomizableKeys(msg); + (*msg)[am::strings::msg_params][am::strings::keyboard_properties] + [am::hmi_request::keyboard_layout] = + hmi_apis::Common_KeyboardLayout::QWERTZ; + + const int num_allowed_keys = 0; + auto display_capabilities = GetCapabilitiesForConfigurableKeyboard( + hmi_apis::Common_KeyboardLayout::QWERTZ, num_allowed_keys); + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, display_capabilities()) + .WillByDefault(Return(display_capabilities)); + std::shared_ptr command( + CreateCommand(msg)); + + ExpectInvalidData(); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, + Run_DisallowedNumberOfCustomizableKeysAndSavedLayout_INVALID_DATA) { + MessageSharedPtr msg = CreateMsgParams(); + AddCustomizableKeys(msg); + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + auto saved_keyboard_props = SmartObject(smart_objects::SmartType_Map); + saved_keyboard_props[am::hmi_request::keyboard_layout] = + hmi_apis::Common_KeyboardLayout::QWERTZ; + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillOnce(Return(&saved_keyboard_props)); + + const int num_allowed_keys = 0; + auto display_capabilities = GetCapabilitiesForConfigurableKeyboard( + hmi_apis::Common_KeyboardLayout::QWERTZ, num_allowed_keys); + + ON_CALL(*mock_app_, display_capabilities()) + .WillByDefault(Return(display_capabilities)); + std::shared_ptr command( + CreateCommand(msg)); + + ExpectInvalidData(); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, + Run_DisallowedNumberOfCustomizableKeysAndDefaultLayout_INVALID_DATA) { + MessageSharedPtr msg = CreateMsgParams(); + AddCustomizableKeys(msg); + + const int num_allowed_keys = 0; + auto display_capabilities = GetCapabilitiesForConfigurableKeyboard( + hmi_apis::Common_KeyboardLayout::QWERTY, num_allowed_keys); + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, display_capabilities()) + .WillByDefault(Return(display_capabilities)); + std::shared_ptr command( + CreateCommand(msg)); + + ExpectInvalidData(); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, + Run_AllowedNumberOfCustomizableKeysAndNotSupportedLayout_INVALID_DATA) { + MessageSharedPtr msg = CreateMsgParams(); + AddCustomizableKeys(msg); + (*msg)[am::strings::msg_params][am::strings::keyboard_properties] + [am::hmi_request::keyboard_layout] = + hmi_apis::Common_KeyboardLayout::QWERTZ; + + const int num_allowed_keys = 3; + auto display_capabilities = GetCapabilitiesForConfigurableKeyboard( + hmi_apis::Common_KeyboardLayout::QWERTY, num_allowed_keys); + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, display_capabilities()) + .WillByDefault(Return(display_capabilities)); + std::shared_ptr command( + CreateCommand(msg)); + + ExpectInvalidData(); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, + Run_AllowedNumberOfCustomizableKeys_LayoutFromRequestCached) { + MessageSharedPtr msg = CreateMsgParams(); + AddCustomizableKeys(msg); + auto& keyboard_properties = + (*msg)[am::strings::msg_params][am::strings::keyboard_properties]; + keyboard_properties[am::hmi_request::keyboard_layout] = + hmi_apis::Common_KeyboardLayout::QWERTY; + + const int num_allowed_keys = 3; + auto display_capabilities = GetCapabilitiesForConfigurableKeyboard( + hmi_apis::Common_KeyboardLayout::QWERTY, num_allowed_keys); + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, display_capabilities()) + .WillByDefault(Return(display_capabilities)); + std::shared_ptr command( + CreateCommand(msg)); + + EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + + command->Run(); +} + +TEST_F( + SetGlobalPropertiesRequestTest, + Run_AllowedNumberOfCustomizableKeysAndSavedLayout_SavedLayoutCachedAgain) { + MessageSharedPtr msg = CreateMsgParams(); + AddCustomizableKeys(msg); + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + auto saved_keyboard_props = SmartObject(smart_objects::SmartType_Map); + saved_keyboard_props[am::hmi_request::keyboard_layout] = + hmi_apis::Common_KeyboardLayout::QWERTZ; + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillRepeatedly(Return(&saved_keyboard_props)); + + const int num_allowed_keys = 3; + auto display_capabilities = GetCapabilitiesForConfigurableKeyboard( + hmi_apis::Common_KeyboardLayout::QWERTZ, num_allowed_keys); + + ON_CALL(*mock_app_, display_capabilities()) + .WillByDefault(Return(display_capabilities)); + std::shared_ptr command( + CreateCommand(msg)); + + auto requested_keyboard_properties = + (*msg)[am::strings::msg_params][am::strings::keyboard_properties]; + auto cached_keyboard_props(requested_keyboard_properties); + cached_keyboard_props[am::hmi_request::keyboard_layout] = + hmi_apis::Common_KeyboardLayout::QWERTZ; + EXPECT_CALL(*mock_app_, set_keyboard_props(cached_keyboard_props)); + + command->Run(); +} + +TEST_F( + SetGlobalPropertiesRequestTest, + Run_AllowedNumberOfCustomizableKeysAndDefaultLayout_KeyboardPropsCachedAsIs) { + MessageSharedPtr msg = CreateMsgParams(); + AddCustomizableKeys(msg); + + const int num_allowed_keys = 3; + auto display_capabilities = GetCapabilitiesForConfigurableKeyboard( + hmi_apis::Common_KeyboardLayout::QWERTY, num_allowed_keys); + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + ON_CALL(*mock_app_, display_capabilities()) + .WillByDefault(Return(display_capabilities)); + std::shared_ptr command( + CreateCommand(msg)); + + auto requested_keyboard_properties = + (*msg)[am::strings::msg_params][am::strings::keyboard_properties]; + EXPECT_CALL(*mock_app_, set_keyboard_props(requested_keyboard_properties)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, + Run_RequestContainsLanguageParam_KeyboardPropsCachedAsIs) { + MessageSharedPtr msg = CreateMsgParams(); + auto& keyboard_properties = + (*msg)[am::strings::msg_params][am::strings::keyboard_properties]; + keyboard_properties[am::hmi_response::language] = + hmi_apis::Common_Language::EN_GB; + + std::shared_ptr command( + CreateCommand(msg)); + + EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, + Run_NoLanguageInRequestButPresentInSaved_SavedLanguageCachedAgain) { + MessageSharedPtr msg = CreateMsgParams(); + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + auto saved_keyboard_props = SmartObject(smart_objects::SmartType_Map); + saved_keyboard_props[am::hmi_response::language] = + hmi_apis::Common_Language::EN_GB; + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillRepeatedly(Return(&saved_keyboard_props)); + + std::shared_ptr command( + CreateCommand(msg)); + + auto cached_keyboard_props = + (*msg)[am::strings::msg_params][am::strings::keyboard_properties]; + cached_keyboard_props[am::hmi_response::language] = + hmi_apis::Common_Language::EN_GB; + EXPECT_CALL(*mock_app_, set_keyboard_props(cached_keyboard_props)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, + Run_RequestContainsMaskInputCharactersParam_KeyboardPropsCachedAsIs) { + MessageSharedPtr msg = CreateMsgParams(); + auto& keyboard_properties = + (*msg)[am::strings::msg_params][am::strings::keyboard_properties]; + keyboard_properties[am::hmi_request::mask_input_characters] = + hmi_apis::Common_KeyboardInputMask::ENABLE_INPUT_KEY_MASK; + + std::shared_ptr command( + CreateCommand(msg)); + + EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + + command->Run(); +} + +TEST_F( + SetGlobalPropertiesRequestTest, + Run_NoMaskInputCharactersInRequestButPresentInSaved_SavedParamCachedAgain) { + MessageSharedPtr msg = CreateMsgParams(); + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + auto saved_keyboard_props = SmartObject(smart_objects::SmartType_Map); + saved_keyboard_props[am::hmi_request::mask_input_characters] = + hmi_apis::Common_KeyboardInputMask::USER_CHOICE_INPUT_KEY_MASK; + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillRepeatedly(Return(&saved_keyboard_props)); + + std::shared_ptr command( + CreateCommand(msg)); + + auto cached_keyboard_props = + (*msg)[am::strings::msg_params][am::strings::keyboard_properties]; + cached_keyboard_props[am::hmi_request::mask_input_characters] = + hmi_apis::Common_KeyboardInputMask::USER_CHOICE_INPUT_KEY_MASK; + EXPECT_CALL(*mock_app_, set_keyboard_props(cached_keyboard_props)); + + command->Run(); +} + +TEST_F(SetGlobalPropertiesRequestTest, + Run_NoAutocompleteListInRequestButPresentInSaved_SavedArrayCachedAgain) { + MessageSharedPtr msg = CreateMsgParams(); + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + auto saved_keyboard_props = SmartObject(smart_objects::SmartType_Map); + + SmartObject autocomplete_list(smart_objects::SmartType_Array); + autocomplete_list[0] = "first"; + autocomplete_list[1] = "second"; + saved_keyboard_props[am::hmi_request::auto_complete_list] = autocomplete_list; + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillRepeatedly(Return(&saved_keyboard_props)); + + std::shared_ptr command( + CreateCommand(msg)); + + auto cached_keyboard_props = + (*msg)[am::strings::msg_params][am::strings::keyboard_properties]; + cached_keyboard_props[am::hmi_request::auto_complete_list] = + autocomplete_list; + EXPECT_CALL(*mock_app_, set_keyboard_props(cached_keyboard_props)); + + command->Run(); +} + +TEST_F( + SetGlobalPropertiesRequestTest, + Run_NewAutocompleteListInRequestAndAlsoPresentInSaved_TransferAndSaveNewArray) { + MessageSharedPtr msg = CreateMsgParams(); + + auto& keyboard_properties = + (*msg)[am::strings::msg_params][am::strings::keyboard_properties]; + SmartObject new_list(smart_objects::SmartType_Array); + new_list[0] = "first_new_value"; + new_list[1] = "second_new_value"; + keyboard_properties[am::hmi_request::auto_complete_list] = new_list; + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + SmartObject old_list(smart_objects::SmartType_Array); + old_list[0] = "old_value"; + old_list[1] = "another_old_value"; + auto saved_keyboard_props = SmartObject(smart_objects::SmartType_Map); + saved_keyboard_props[am::hmi_request::auto_complete_list] = old_list; + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillRepeatedly(Return(&saved_keyboard_props)); + + std::shared_ptr command( + CreateCommand(msg)); + + EXPECT_CALL(*mock_app_, set_keyboard_props(keyboard_properties)); + + command->Run(); +} + +TEST_F( + SetGlobalPropertiesRequestTest, + Run_EmptyAutocompleteListInRequestAndAlsoPresentInSaved_TransferButNotSaveEmptyArray) { + MessageSharedPtr msg = CreateMsgParams(); + + auto& keyboard_properties = + (*msg)[am::strings::msg_params][am::strings::keyboard_properties]; + SmartObject new_list(smart_objects::SmartType_Array); + keyboard_properties[am::hmi_request::auto_complete_list] = new_list; + + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + SmartObject old_list(smart_objects::SmartType_Array); + old_list[0] = "old_value"; + old_list[1] = "another_old_value"; + auto saved_keyboard_props = SmartObject(smart_objects::SmartType_Map); + saved_keyboard_props[am::hmi_request::auto_complete_list] = old_list; + EXPECT_CALL(*mock_app_, keyboard_props()) + .WillRepeatedly(Return(&saved_keyboard_props)); + + std::shared_ptr command( + CreateCommand(msg)); + + auto properties_without_empty_list(keyboard_properties); + properties_without_empty_list.erase(am::hmi_request::auto_complete_list); + EXPECT_CALL(*mock_app_, set_keyboard_props(properties_without_empty_list)); + + command->Run(); +} + TEST_F(SetGlobalPropertiesRequestTest, Run_NoData_Canceled) { MessageSharedPtr msg = CreateMsgParams(); 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 0034dcf9162..d091fdc8c57 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 @@ -93,15 +93,12 @@ class MobileResponseCommandsTest typedef TypesRun(); } +template +class MobileResponseWithUnsubscribeCommandsTest + : public CommandsTest { + public: + typedef CommandWithUnsubscribe UnsubscribeCommand; +}; + +typedef Types + ResponseWithUnsubscribeCommandList; + +TYPED_TEST_CASE(MobileResponseWithUnsubscribeCommandsTest, + ResponseWithUnsubscribeCommandList); + +TYPED_TEST(MobileResponseWithUnsubscribeCommandsTest, + RunWithUnsubscribe_SUCCESS) { + std::shared_ptr command = + this->template CreateCommand(); + + EXPECT_CALL(this->app_mngr_, UnsubscribeAppFromSoftButtons(_)); + EXPECT_CALL(this->mock_rpc_service_, SendMessageToMobile(NotNull(), _)); + + command->Init(); + command->Run(); +} + class GenericResponseFromHMICommandsTest : public CommandsTest {}; @@ -145,7 +170,6 @@ MATCHER_P2(CheckMessageParams, success, result, "") { result == static_cast( (*arg)[am::strings::msg_params][am::strings::result_code].asInt()); - using namespace helpers; return Compare( true, is_msg_type_correct, is_success_correct, is_result_code_correct); @@ -164,24 +188,6 @@ TEST_F(GenericResponseFromHMICommandsTest, Run_SUCCESS) { command->Run(); } - -class ScrollableMessageResponseTest - : public CommandsTest {}; - -TEST_F(ScrollableMessageResponseTest, Run_SUCCESS) { - MessageSharedPtr message = CreateMessage(); - (*message)[am::strings::msg_params][am::strings::result_code] = - mobile_apis::Result::SUCCESS; - - MockAppPtr app(CreateMockApp()); - - std::shared_ptr command( - CreateCommand(message)); - EXPECT_CALL(app_mngr_, application(_)).WillOnce(Return(app)); - EXPECT_CALL(*app, UnsubscribeFromSoftButtons(_)); - command->Run(); -} - } // namespace simple_response_commands_test } // namespace mobile_commands_test } // namespace commands_test 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 528f8a07000..44c5a7a3dda 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 @@ -73,13 +73,12 @@ TEST_F(SubscribeWayPointsRequestTest, Run_SUCCESS) { ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app)); ON_CALL(app_mngr_, IsAppSubscribedForWayPoints(Ref(*app))) .WillByDefault(Return(false)); - ON_CALL(app_mngr_, IsAnyAppSubscribedForWayPoints()) - .WillByDefault(Return(true)); + ON_CALL(app_mngr_, IsSubscribedToHMIWayPoints()).WillByDefault(Return(true)); { InSequence dummy; EXPECT_CALL(app_mngr_, - SubscribeAppForWayPoints(A())); + SubscribeAppForWayPoints(A(), false)); EXPECT_CALL(*app, UpdateHash()); } @@ -112,7 +111,7 @@ TEST_F(SubscribeWayPointsRequestTest, OnEvent_SUCCESS) { { InSequence dummy; EXPECT_CALL(app_mngr_, - SubscribeAppForWayPoints(A())); + SubscribeAppForWayPoints(A(), true)); EXPECT_CALL(mock_message_helper_, HMIToMobileResult(result_code)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); 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 ec4d2420d6f..9a6ff4d14ee 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 @@ -123,6 +123,8 @@ TEST_F(UnsubscribeWayPointsRequestTest, Run_AppSubscribedForWayPoints_SUCCESS) { EXPECT_CALL(app_mngr_, GetAppsSubscribedForWayPoints()) .WillOnce(Return(subscribed_apps)); + EXPECT_CALL(app_mngr_, IsSubscribedToHMIWayPoints()).WillOnce(Return(true)); + EXPECT_CALL(mock_rpc_service_, ManageHMICommand( HMIResultCodeIs( @@ -156,9 +158,10 @@ TEST_F(UnsubscribeWayPointsRequestTest, Event event(hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints); event.set_smart_object(*event_msg); - EXPECT_CALL(app_mngr_, - UnsubscribeAppFromWayPoints( - ::testing::Matcher(mock_app))); + EXPECT_CALL( + app_mngr_, + UnsubscribeAppFromWayPoints( + ::testing::Matcher(mock_app), true)); EXPECT_CALL( mock_rpc_service_, 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 dbd1b480339..19c1113cc61 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 @@ -55,11 +55,10 @@ void VIGetVehicleTypeResponse::Run() { const auto result_code = static_cast( (*message_)[strings::params][hmi_response::code].asInt()); - hmi_capabilities_.UpdateRequestsRequiredForCapabilities( - hmi_apis::FunctionID::VehicleInfo_GetVehicleType); - if (hmi_apis::Common_Result::SUCCESS != result_code) { SDL_LOG_DEBUG("Request was not successful. Don't change HMI capabilities"); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::VehicleInfo_GetVehicleType); return; } @@ -67,6 +66,9 @@ void VIGetVehicleTypeResponse::Run() { hmi_capabilities_.set_vehicle_type( (*message_)[strings::msg_params][hmi_response::vehicle_type]); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::VehicleInfo_GetVehicleType); + if (!hmi_capabilities_.SaveCachedCapabilitiesToFile( hmi_interface::vehicle_info, sections_to_update, 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 578f650e985..2c9ac785235 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 @@ -78,6 +78,8 @@ void VIIsReadyRequest::on_event(const event_engine::Event& event) { HMICapabilities& hmi_capabilities = hmi_capabilities_; hmi_capabilities.set_is_ivi_cooperating(is_available); policy_handler_.OnVIIsReady(); + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::VehicleInfo_IsReady); if (!app_mngr::commands::CheckAvailabilityHMIInterfaces( application_manager_, HmiInterfaces::HMI_INTERFACE_VehicleInfo)) { SDL_LOG_INFO( @@ -99,6 +101,8 @@ void VIIsReadyRequest::on_event(const event_engine::Event& event) { void VIIsReadyRequest::onTimeOut() { // Note(dtrunov): According to new requirment APPLINK-27956 + hmi_capabilities_.UpdateRequestsRequiredForCapabilities( + hmi_apis::FunctionID::VehicleInfo_IsReady); RequestInterfaceCapabilities(hmi_interface ::vehicle_info); } 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 e336b778ffd..60dea0a24b1 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 @@ -103,10 +103,41 @@ void OnVehicleDataNotification::Run() { } } - SDL_LOG_DEBUG("Number of Notifications to be send: " << notify_apps.size()); - for (size_t idx = 0; idx < notify_apps.size(); idx++) { - SDL_LOG_INFO("Send OnVehicleData PRNDL notification to " + CommandParametersPermissions params_permissions; + application_manager_.CheckPolicyPermissions( + notify_apps[idx], + window_id(), + MessageHelper::StringifiedFunctionID( + mobile_api::FunctionID::OnVehicleDataID), + appSO[idx].enumerate(), + ¶ms_permissions); + if (params_permissions.allowed_params.empty() && + params_permissions.disallowed_params.empty() && + params_permissions.undefined_params.empty()) { + SDL_LOG_DEBUG( + "No parameter permissions provided, all params are allowed"); + } else { + for (const auto& param : appSO[idx].enumerate()) { + const auto& allowed_params = params_permissions.allowed_params; + auto param_allowed = allowed_params.find(param); + if (allowed_params.end() == param_allowed) { + SDL_LOG_DEBUG("Param " << param + << " is not allowed by policy for app " + << notify_apps[idx]->app_id() + << ". It will be ignored."); + appSO[idx].erase(param); + } + } + } + + if (appSO[idx].empty()) { + SDL_LOG_DEBUG("App " << notify_apps[idx]->app_id() + << " will be skipped: there is nothing to notify."); + continue; + } + + SDL_LOG_INFO("Send OnVehicleData notification to " << notify_apps[idx]->name().c_str() << " application id " << notify_apps[idx]->app_id()); (*message_)[strings::params][strings::connection_key] = 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 8ffeaf922a9..7d81701a644 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 @@ -314,8 +314,8 @@ bool UnsubscribeVehicleDataRequest::CheckSubscriptionStatus( bool UnsubscribeVehicleDataRequest::UnsubscribePendingVehicleData( ApplicationSharedPtr app, const smart_objects::SmartObject& msg_params) { SDL_LOG_DEBUG("Unsubscribing from all pending VehicleData"); - - for (const auto& vi_name : vi_waiting_for_unsubscribe_) { + auto pending_vi = vi_waiting_for_unsubscribe_; + for (const auto& vi_name : pending_vi) { const auto converted_item = ConvertRequestToResponseName(vi_name); const bool is_unsubscription_successful = CheckSubscriptionStatus(converted_item, msg_params); 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 82eb19c45f9..3f8dcbb4881 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 @@ -56,8 +56,10 @@ namespace on_vehicle_data_notification { namespace am = ::application_manager; using ::testing::_; +using ::testing::ContainerEq; using ::testing::Return; using ::testing::ReturnRef; +using ::testing::SetArgPointee; using am::commands::MessageSharedPtr; using vehicle_info_plugin::commands::OnVehicleDataNotification; @@ -119,6 +121,15 @@ TEST_F(OnVehicleDataNotificationTest, OnVehicleDataNotification_SUCCESS) { VehicleInfoAppExtensionUID)) .WillByDefault(Return(vi_app_extention_ptr)); + am::CommandParametersPermissions params_permissions; + params_permissions.allowed_params.insert(am::strings::gps); + params_permissions.allowed_params.insert(am::strings::speed); + EXPECT_CALL(app_mngr_, + CheckPolicyPermissions( + _, _, _, ContainerEq(params_permissions.allowed_params), _)) + .WillOnce(DoAll(SetArgPointee<4>(params_permissions), + Return(mobile_apis::Result::SUCCESS))); + MessageSharedPtr message(CreateMessage(smart_objects::SmartType_Map)); smart_objects::SmartObject gps_data; gps_data[am::strings::longitude_degrees] = 1.0; diff --git a/src/components/application_manager/src/app_service_manager.cc b/src/components/application_manager/src/app_service_manager.cc index 9b31d57ca05..4955c792c20 100644 --- a/src/components/application_manager/src/app_service_manager.cc +++ b/src/components/application_manager/src/app_service_manager.cc @@ -617,6 +617,25 @@ bool AppServiceManager::UpdateNavigationCapabilities( return true; } +AppService* AppServiceManager::FindWayPointsHandler() { + auto service = ActiveServiceForType( + EnumToString(mobile_apis::AppServiceType::NAVIGATION)); + if (!service || !service->mobile_service || + !service->record[strings::service_manifest].keyExists( + strings::handled_rpcs)) { + return nullptr; + } + + smart_objects::SmartObject& handled_rpcs = + service->record[strings::service_manifest][strings::handled_rpcs]; + for (size_t i = 0; i < handled_rpcs.length(); ++i) { + if (handled_rpcs[i].asInt() == mobile_apis::FunctionID::GetWayPointsID) { + return service; + } + } + return nullptr; +} + void AppServiceManager::AppServiceUpdated( const smart_objects::SmartObject& service_record, const mobile_apis::ServiceUpdateReason::eType update_reason, diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 6b4500e394d..2952fd54812 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -613,9 +613,6 @@ void ApplicationImpl::StopStreaming( void ApplicationImpl::StopNaviStreaming() { SDL_LOG_AUTO_TRACE(); video_stream_suspend_timer_.Stop(); - application_manager_.OnAppStreaming(app_id(), - protocol_handler::ServiceType::kMobileNav, - StreamingState::kStopped); MessageHelper::SendNaviStopStream(app_id(), application_manager_); set_video_streaming_approved(false); set_video_stream_retry_number(0); @@ -624,9 +621,6 @@ void ApplicationImpl::StopNaviStreaming() { void ApplicationImpl::StopAudioStreaming() { SDL_LOG_AUTO_TRACE(); audio_stream_suspend_timer_.Stop(); - application_manager_.OnAppStreaming(app_id(), - protocol_handler::ServiceType::kAudio, - StreamingState::kStopped); MessageHelper::SendAudioStopStream(app_id(), application_manager_); set_audio_streaming_approved(false); set_audio_stream_retry_number(0); @@ -637,17 +631,14 @@ void ApplicationImpl::SuspendStreaming( using namespace protocol_handler; SDL_LOG_AUTO_TRACE(); - if (ServiceType::kMobileNav == service_type && !video_streaming_suspended_) { + if (ServiceType::kMobileNav == service_type) { video_stream_suspend_timer_.Stop(); - application_manager_.OnAppStreaming( - app_id(), service_type, StreamingState::kSuspended); + application_manager_.OnAppStreaming(app_id(), service_type, false); sync_primitives::AutoLock lock(video_streaming_suspended_lock_); video_streaming_suspended_ = true; - } else if (ServiceType::kAudio == service_type && - !audio_streaming_suspended_) { + } else if (ServiceType::kAudio == service_type) { audio_stream_suspend_timer_.Stop(); - application_manager_.OnAppStreaming( - app_id(), service_type, StreamingState::kSuspended); + application_manager_.OnAppStreaming(app_id(), service_type, false); sync_primitives::AutoLock lock(audio_streaming_suspended_lock_); audio_streaming_suspended_ = true; } @@ -656,7 +647,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; SDL_LOG_AUTO_TRACE(); @@ -668,29 +659,28 @@ void ApplicationImpl::WakeUpStreaming( { // reduce the range of video_streaming_suspended_lock_ sync_primitives::AutoLock auto_lock(video_streaming_suspended_lock_); if (video_streaming_suspended_) { - application_manager_.OnAppStreaming( - app_id(), service_type, StreamingState::kStarted); + application_manager_.OnAppStreaming(app_id(), service_type, true); application_manager_.ProcessOnDataStreamingNotification( service_type, app_id(), true); 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) { { // reduce the range of audio_streaming_suspended_lock_ sync_primitives::AutoLock auto_lock(audio_streaming_suspended_lock_); if (audio_streaming_suspended_) { - application_manager_.OnAppStreaming( - app_id(), service_type, StreamingState::kStarted); + application_manager_.OnAppStreaming(app_id(), service_type, true); application_manager_.ProcessOnDataStreamingNotification( service_type, app_id(), true); 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); } } @@ -1147,20 +1137,36 @@ uint32_t ApplicationImpl::GetAvailableDiskSpace() { } void ApplicationImpl::SubscribeToSoftButtons( - int32_t cmd_id, const SoftButtonID& softbuttons_id) { + int32_t cmd_id, const WindowSoftButtons& window_softbuttons) { sync_primitives::AutoLock lock(cmd_softbuttonid_lock_); - if (static_cast(mobile_apis::FunctionID::ScrollableMessageID) == - cmd_id) { - CommandSoftButtonID::iterator it = cmd_softbuttonid_.find(cmd_id); - if (cmd_softbuttonid_.end() == it) { - cmd_softbuttonid_[cmd_id] = softbuttons_id; - } - } else { - auto& soft_button_ids = cmd_softbuttonid_[cmd_id]; - for (auto& softbutton_item : softbuttons_id) { - soft_button_ids.insert(softbutton_item); - } + CommandSoftButtonID::iterator it = cmd_softbuttonid_.find(cmd_id); + + if (cmd_softbuttonid_.end() == it) { + SoftButtonIDs soft_buttons{window_softbuttons}; + cmd_softbuttonid_.insert({cmd_id, soft_buttons}); + return; + } + + auto& command_soft_buttons = cmd_softbuttonid_[cmd_id]; + + const auto window_id = window_softbuttons.first; + auto find_window_id = [window_id](const WindowSoftButtons& window_buttons) { + return window_id == window_buttons.first; + }; + + auto subscribed_window_buttons = std::find_if( + command_soft_buttons.begin(), command_soft_buttons.end(), find_window_id); + + if (subscribed_window_buttons == command_soft_buttons.end()) { + command_soft_buttons.insert(window_softbuttons); + return; } + + WindowSoftButtons new_window_soft_buttons = *subscribed_window_buttons; + new_window_soft_buttons.second.insert(window_softbuttons.second.begin(), + window_softbuttons.second.end()); + command_soft_buttons.erase(subscribed_window_buttons); + command_soft_buttons.insert(new_window_soft_buttons); } struct FindSoftButtonId { @@ -1169,24 +1175,46 @@ struct FindSoftButtonId { explicit FindSoftButtonId(const uint32_t soft_button_id) : soft_button_id_(soft_button_id) {} - bool operator()(const std::pair& element) const { - return soft_button_id_ == element.first; + bool operator()(const uint32_t softbutton_id) { + return soft_button_id_ == softbutton_id; + } +}; + +struct FindWindowSoftButtonId { + public: + FindWindowSoftButtonId(const uint32_t soft_button_id) + : find_softbutton_id_(soft_button_id) {} + + bool operator()(const WindowSoftButtons& window_buttons) { + const auto softbuttons = window_buttons.second; + auto found_softbutton = std::find_if( + softbuttons.begin(), softbuttons.end(), find_softbutton_id_); + + return found_softbutton != softbuttons.end(); } + + private: + FindSoftButtonId find_softbutton_id_; }; bool ApplicationImpl::IsSubscribedToSoftButton(const uint32_t softbutton_id) { SDL_LOG_AUTO_TRACE(); 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)) { + + for (const auto& command_soft_buttons : cmd_softbuttonid_) { + FindWindowSoftButtonId find_window_softbutton_id(softbutton_id); + const auto& window_softbuttons = command_soft_buttons.second; + + const auto found_window_softbutton_id = + std::find_if(window_softbuttons.begin(), + window_softbuttons.end(), + find_window_softbutton_id); + + if (found_window_softbutton_id != window_softbuttons.end()) { return true; } } + return false; } @@ -1194,14 +1222,18 @@ WindowID ApplicationImpl::GetSoftButtonWindowID(const uint32_t softbutton_id) { SDL_LOG_AUTO_TRACE(); 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; + + for (const auto& command_soft_buttons : cmd_softbuttonid_) { + FindWindowSoftButtonId find_window_softbutton_id(softbutton_id); + const auto& window_softbuttons = command_soft_buttons.second; + + const auto found_window_softbutton_id = + std::find_if(window_softbuttons.begin(), + window_softbuttons.end(), + find_window_softbutton_id); + + if (found_window_softbutton_id != window_softbuttons.end()) { + return found_window_softbutton_id->first; } } diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 6b0ea398045..948f7944d46 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -145,10 +145,6 @@ struct PolicyAppIdComparator { const std::string& policy_app_id_; }; -uint32_t ApplicationManagerImpl::mobile_corelation_id_ = 0; -uint32_t ApplicationManagerImpl::corelation_id_ = 0; -const uint32_t ApplicationManagerImpl::max_corelation_id_ = UINT_MAX; - namespace formatters = ns_smart_device_link::ns_json_handler::formatters; namespace jhs = ns_smart_device_link::ns_json_handler::strings; @@ -162,6 +158,7 @@ ApplicationManagerImpl::ApplicationManagerImpl( std::make_shared()) , apps_to_register_list_lock_ptr_(std::make_shared()) , reregister_wait_list_lock_ptr_(std::make_shared()) + , subscribed_to_hmi_way_points_(false) , audio_pass_thru_active_(false) , audio_pass_thru_app_id_(0) , driver_distraction_state_(hmi_apis::Common_DriverDistractionState::DD_OFF) @@ -174,8 +171,9 @@ ApplicationManagerImpl::ApplicationManagerImpl( , policy_handler_(new policy::PolicyHandler(policy_settings, *this)) , protocol_handler_(NULL) , request_ctrl_(am_settings) - , hmi_so_factory_(NULL) - , mobile_so_factory_(NULL) + , mobile_correlation_id_(0) + , correlation_id_(0) + , max_correlation_id_(UINT_MAX) , hmi_capabilities_(new HMICapabilitiesImpl(*this)) , unregister_reason_( mobile_api::AppInterfaceUnregisteredReason::INVALID_ENUM) @@ -229,19 +227,11 @@ ApplicationManagerImpl::ApplicationManagerImpl( ApplicationManagerImpl::~ApplicationManagerImpl() { SDL_LOG_AUTO_TRACE(); - is_stopping_.store(true); + InitiateStopping(); SendOnSDLClose(); media_manager_ = NULL; hmi_handler_ = NULL; connection_handler_ = NULL; - if (hmi_so_factory_) { - delete hmi_so_factory_; - hmi_so_factory_ = NULL; - } - if (mobile_so_factory_) { - delete mobile_so_factory_; - mobile_so_factory_ = NULL; - } protocol_handler_ = NULL; SDL_LOG_DEBUG("Destroying Policy Handler"); RemovePolicyObserver(this); @@ -673,17 +663,8 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( static_cast( message[strings::params][strings::protocol_version].asInt()); application->set_protocol_version(protocol_version); - - if (protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_UNKNOWN != - protocol_version) { - connection_handler().BindProtocolVersionWithSession( - connection_key, static_cast(protocol_version)); - } - if ((protocol_version == - protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3) && - (get_settings().heart_beat_timeout() != 0)) { - connection_handler().StartSessionHeartBeat(connection_key); - } + connection_handler_->BindProtocolVersionWithSession(connection_key, + protocol_version); // Keep HMI add id in case app is present in "waiting for registration" list apps_to_register_list_lock_ptr_->Acquire(); @@ -1382,23 +1363,23 @@ ApplicationManagerImpl::GetCloudAppConnectionStatus( } uint32_t ApplicationManagerImpl::GetNextMobileCorrelationID() { - if (mobile_corelation_id_ < max_corelation_id_) { - mobile_corelation_id_++; + if (mobile_correlation_id_ < max_correlation_id_) { + mobile_correlation_id_++; } else { - mobile_corelation_id_ = 0; + mobile_correlation_id_ = 0; } - return mobile_corelation_id_; + return mobile_correlation_id_; } uint32_t ApplicationManagerImpl::GetNextHMICorrelationID() { - if (corelation_id_ < max_corelation_id_) { - corelation_id_++; + if (correlation_id_ < max_correlation_id_) { + correlation_id_++; } else { - corelation_id_ = 0; + correlation_id_ = 0; } - return corelation_id_; + return correlation_id_; } bool ApplicationManagerImpl::BeginAudioPassThru(uint32_t app_id) { @@ -1616,6 +1597,58 @@ void ApplicationManagerImpl::OnDeviceListUpdated( RefreshCloudAppInformation(); } +bool ApplicationManagerImpl::WaitForHmiIsReady() { + sync_primitives::AutoLock lock(wait_for_hmi_lock_); + if (!IsStopping() && !IsHMICooperating()) { + SDL_LOG_DEBUG("Waiting for the HMI cooperation..."); + wait_for_hmi_condvar_.Wait(lock); + } + + if (IsStopping()) { + SDL_LOG_WARN("System is terminating..."); + return false; + } + + return IsHMICooperating(); +} + +bool ApplicationManagerImpl::GetProtocolVehicleData( + connection_handler::ProtocolVehicleData& data) { + SDL_LOG_AUTO_TRACE(); + using namespace protocol_handler::strings; + + if (!WaitForHmiIsReady()) { + SDL_LOG_ERROR("Failed to wait for HMI readiness"); + return false; + } + + const auto vehicle_type_ptr = hmi_capabilities_->vehicle_type(); + if (vehicle_type_ptr) { + if (vehicle_type_ptr->keyExists(vehicle_make)) { + data.vehicle_make = vehicle_type_ptr->getElement(vehicle_make).asString(); + } + + if (vehicle_type_ptr->keyExists(vehicle_model)) { + data.vehicle_model = + vehicle_type_ptr->getElement(vehicle_model).asString(); + } + + if (vehicle_type_ptr->keyExists(vehicle_model_year)) { + data.vehicle_year = + vehicle_type_ptr->getElement(vehicle_model_year).asString(); + } + + if (vehicle_type_ptr->keyExists(vehicle_trim)) { + data.vehicle_trim = vehicle_type_ptr->getElement(vehicle_trim).asString(); + } + } + + data.vehicle_system_software_version = hmi_capabilities_->ccpu_version(); + data.vehicle_system_hardware_version = hmi_capabilities_->hardware_version(); + + return true; +} + void ApplicationManagerImpl::OnFindNewApplicationsRequest() { connection_handler().ConnectToAllDevices(); SDL_LOG_DEBUG("Starting application list update timer"); @@ -1731,11 +1764,11 @@ void ApplicationManagerImpl::SwitchApplication(ApplicationSharedPtr app, bool is_subscribed_to_way_points = IsAppSubscribedForWayPoints(*app); if (is_subscribed_to_way_points) { - UnsubscribeAppFromWayPoints(app); + UnsubscribeAppFromWayPoints(app, false); } SwitchApplicationParameters(app, connection_key, device_id, mac_address); if (is_subscribed_to_way_points) { - SubscribeAppForWayPoints(app); + SubscribeAppForWayPoints(app, false); } // Normally this is done during registration, however since switched apps are @@ -2555,7 +2588,7 @@ bool ApplicationManagerImpl::Init( bool ApplicationManagerImpl::Stop() { SDL_LOG_AUTO_TRACE(); - is_stopping_.store(true); + InitiateStopping(); application_list_update_timer_.Stop(); try { if (unregister_reason_ == @@ -2681,25 +2714,16 @@ bool ApplicationManagerImpl::ConvertSOtoMessage( } hmi_apis::HMI_API& ApplicationManagerImpl::hmi_so_factory() { - if (!hmi_so_factory_) { - hmi_so_factory_ = new hmi_apis::HMI_API; - if (!hmi_so_factory_) { - SDL_LOG_ERROR("Out of memory"); - NOTREACHED(); - } - } - return *hmi_so_factory_; + return hmi_so_factory_; } mobile_apis::MOBILE_API& ApplicationManagerImpl::mobile_so_factory() { - if (!mobile_so_factory_) { - mobile_so_factory_ = new mobile_apis::MOBILE_API; - if (!mobile_so_factory_) { - SDL_LOG_ERROR("Out of memory"); - NOTREACHED(); - } - } - return *mobile_so_factory_; + return mobile_so_factory_; +} + +ns_smart_device_link_rpc::V1::v4_protocol_v1_2_no_extra& +ApplicationManagerImpl::mobile_v4_protocol_so_factory() { + return mobile_v4_protocol_so_factory_; } HMICapabilities& ApplicationManagerImpl::hmi_capabilities() { @@ -2979,7 +3003,7 @@ void ApplicationManagerImpl::SetUnregisterAllApplicationsReason( void ApplicationManagerImpl::HeadUnitReset( mobile_api::AppInterfaceUnregisteredReason::eType reason) { SDL_LOG_AUTO_TRACE(); - is_stopping_.store(true); + InitiateStopping(); switch (reason) { case mobile_api::AppInterfaceUnregisteredReason::MASTER_RESET: { SDL_LOG_TRACE("Performing MASTER_RESET"); @@ -3231,6 +3255,7 @@ void ApplicationManagerImpl::UnregisterApplication( } ApplicationSharedPtr app_to_remove; connection_handler::DeviceHandle handle = 0; + { sync_primitives::AutoLock lock(applications_list_lock_ptr_); auto it_app = applications_.begin(); @@ -3243,64 +3268,65 @@ void ApplicationManagerImpl::UnregisterApplication( ++it_app; } } - if (!app_to_remove) { - SDL_LOG_ERROR("Cant find application with app_id = " << app_id); - - // Just to terminate RAI in case of connection is dropped (rare case) - // App won't be unregistered since RAI has not been started yet - SDL_LOG_DEBUG("Trying to terminate possible RAI request."); - request_ctrl_.terminateAppRequests(app_id); - - return; - } + } + if (!app_to_remove) { + SDL_LOG_ERROR("Cant find application with app_id = " << app_id); - if (is_resuming) { - resume_controller().SaveApplication(app_to_remove); - } else { - resume_controller().RemoveApplicationFromSaved(app_to_remove); - } + // Just to terminate RAI in case of connection is dropped (rare case) + // App won't be unregistered since RAI has not been started yet + SDL_LOG_DEBUG("Trying to terminate possible RAI request."); + request_ctrl_.terminateAppRequests(app_id); - if (IsAppSubscribedForWayPoints(app_id)) { - UnsubscribeAppFromWayPoints(app_id); - if (!IsAnyAppSubscribedForWayPoints()) { - SDL_LOG_DEBUG("Send UnsubscribeWayPoints"); - auto request = MessageHelper::CreateUnsubscribeWayPointsRequest( - GetNextHMICorrelationID()); - rpc_service_->ManageHMICommand(request); - } - } + return; + } - (hmi_capabilities_->get_hmi_language_handler()) - .OnUnregisterApplication(app_id); + resume_controller().RemoveFromResumption(app_id); - if (connection_handler().GetDeviceID(app_to_remove->mac_address(), - &handle)) { - AppV4DevicePredicate finder(handle); - ApplicationSharedPtr app = FindApp(applications(), finder); - if (!app) { - SDL_LOG_DEBUG( - "There is no more SDL4 apps with device handle: " << handle); + if (is_resuming) { + resume_controller().SaveApplication(app_to_remove); + } else { + resume_controller().RemoveApplicationFromSaved(app_to_remove); + } - RemoveAppsWaitingForRegistration(handle); - } + if (IsAppSubscribedForWayPoints(app_id)) { + UnsubscribeAppFromWayPoints(app_id, true); + if (!IsAnyAppSubscribedForWayPoints()) { + SDL_LOG_DEBUG("Send UnsubscribeWayPoints"); + auto request = MessageHelper::CreateUnsubscribeWayPointsRequest( + GetNextHMICorrelationID()); + rpc_service_->ManageHMICommand(request); } + } - MessageHelper::SendOnAppUnregNotificationToHMI( - app_to_remove, is_unexpected_disconnect, *this); - commands_holder_->Clear(app_to_remove); + (hmi_capabilities_->get_hmi_language_handler()) + .OnUnregisterApplication(app_id); - const auto enabled_local_apps = policy_handler_->GetEnabledLocalApps(); - if (helpers::in_range(enabled_local_apps, app_to_remove->policy_app_id())) { + if (connection_handler().GetDeviceID(app_to_remove->mac_address(), &handle)) { + AppV4DevicePredicate finder(handle); + ApplicationSharedPtr app = FindApp(applications(), finder); + if (!app) { SDL_LOG_DEBUG( - "Enabled local app has been unregistered. Re-create " - "pending application"); - CreatePendingLocalApplication(app_to_remove->policy_app_id()); + "There is no more SDL4 apps with device handle: " << handle); + + RemoveAppsWaitingForRegistration(handle); } + } - RefreshCloudAppInformation(); - SendUpdateAppList(); + MessageHelper::SendOnAppUnregNotificationToHMI( + app_to_remove, is_unexpected_disconnect, *this); + commands_holder_->Clear(app_to_remove); + + const auto enabled_local_apps = policy_handler_->GetEnabledLocalApps(); + if (helpers::in_range(enabled_local_apps, app_to_remove->policy_app_id())) { + SDL_LOG_DEBUG( + "Enabled local app has been unregistered. Re-create " + "pending application"); + CreatePendingLocalApplication(app_to_remove->policy_app_id()); } + RefreshCloudAppInformation(); + SendUpdateAppList(); + if (EndAudioPassThru(app_id)) { // May be better to put this code in MessageHelper? StopAudioPassThru(app_id); @@ -3582,6 +3608,27 @@ void ApplicationManagerImpl::ForbidStreaming( EndNaviServices(app_id); } +void ApplicationManagerImpl::OnAppStreaming( + uint32_t app_id, protocol_handler::ServiceType service_type, bool state) { + SDL_LOG_AUTO_TRACE(); + + ApplicationSharedPtr app = application(app_id); + if (!app || (!app->is_navi() && !app->mobile_projection_enabled())) { + SDL_LOG_DEBUG( + " There is no navi or projection application with id: " << app_id); + return; + } + DCHECK_OR_RETURN_VOID(media_manager_); + + if (state) { + state_ctrl_.OnVideoStreamingStarted(app); + media_manager_->StartStreaming(app_id, service_type); + } else { + media_manager_->StopStreaming(app_id, service_type); + state_ctrl_.OnVideoStreamingStopped(app); + } +} + void ApplicationManagerImpl::OnAppStreaming( uint32_t app_id, protocol_handler::ServiceType service_type, @@ -4132,7 +4179,17 @@ bool ApplicationManagerImpl::IsHMICooperating() const { } void ApplicationManagerImpl::SetHMICooperating(const bool hmi_cooperating) { + SDL_LOG_AUTO_TRACE(); + sync_primitives::AutoLock lock(wait_for_hmi_lock_); hmi_cooperating_ = hmi_cooperating; + wait_for_hmi_condvar_.Broadcast(); +} + +void ApplicationManagerImpl::InitiateStopping() { + SDL_LOG_AUTO_TRACE(); + sync_primitives::AutoLock lock(wait_for_hmi_lock_); + is_stopping_.store(true); + wait_for_hmi_condvar_.Broadcast(); } void ApplicationManagerImpl::OnApplicationListUpdateTimer() { @@ -4266,6 +4323,10 @@ ResetGlobalPropertiesResult ApplicationManagerImpl::ResetGlobalProperties( result.keyboard_properties = true; break; } + case mobile_apis::GlobalProperty::USER_LOCATION: { + result.user_location = true; + break; + } default: { SDL_LOG_TRACE("Unknown global property: " << global_property); break; @@ -4316,7 +4377,9 @@ ApplicationManagerImpl::CreateAllAppGlobalPropsIDList( if (application->keyboard_props()) { (*global_properties)[i++] = GlobalProperty::KEYBOARDPROPERTIES; } - + if (!application->get_user_location().empty()) { + (*global_properties)[i++] = GlobalProperty::USER_LOCATION; + } return global_properties; } @@ -4725,42 +4788,69 @@ bool ApplicationManagerImpl::IsAppSubscribedForWayPoints( return IsAppSubscribedForWayPoints(app.app_id()); } -void ApplicationManagerImpl::SubscribeAppForWayPoints(uint32_t app_id) { +void ApplicationManagerImpl::SubscribeAppForWayPoints(uint32_t app_id, + bool response_from_hmi) { SDL_LOG_AUTO_TRACE(); sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); SDL_LOG_DEBUG("Subscribing " << app_id); subscribed_way_points_apps_list_.insert(app_id); + if (response_from_hmi) { + subscribed_to_hmi_way_points_ = true; + } SDL_LOG_DEBUG("There are applications subscribed: " << subscribed_way_points_apps_list_.size()); - if (way_points_data_) { - smart_objects::SmartObjectSPtr way_point_notification_ = - std::make_shared(*way_points_data_); - (*way_point_notification_)[strings::params][strings::connection_key] = + if (GetAppServiceManager().FindWayPointsHandler() != nullptr) { + auto service = GetAppServiceManager().ActiveServiceForType( + EnumToString(mobile_apis::AppServiceType::NAVIGATION)); + auto it = mobile_way_points_data_.find(service->connection_key); + if (mobile_way_points_data_.end() == it) { + SDL_LOG_DEBUG("No waypoint data provided by app service provider yet"); + return; + } + smart_objects::SmartObjectSPtr way_point_notification = + std::make_shared(it->second); + (*way_point_notification)[strings::params][strings::connection_key] = + app_id; + GetRPCService().SendMessageToMobile(way_point_notification); + } else if (hmi_way_points_data_) { + smart_objects::SmartObjectSPtr way_point_notification = + std::make_shared(*hmi_way_points_data_); + (*way_point_notification)[strings::params][strings::connection_key] = app_id; - GetRPCService().SendMessageToMobile(way_point_notification_); + GetRPCService().SendMessageToMobile(way_point_notification); } } -void ApplicationManagerImpl::SubscribeAppForWayPoints( - ApplicationSharedPtr app) { - SubscribeAppForWayPoints(app->app_id()); +void ApplicationManagerImpl::SubscribeAppForWayPoints(ApplicationSharedPtr app, + bool response_from_hmi) { + SubscribeAppForWayPoints(app->app_id(), response_from_hmi); } -void ApplicationManagerImpl::UnsubscribeAppFromWayPoints(uint32_t app_id) { +void ApplicationManagerImpl::UnsubscribeAppFromWayPoints( + uint32_t app_id, bool response_from_hmi) { SDL_LOG_AUTO_TRACE(); sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); SDL_LOG_DEBUG("Unsubscribing " << app_id); subscribed_way_points_apps_list_.erase(app_id); + if (response_from_hmi) { + subscribed_to_hmi_way_points_ = false; + } SDL_LOG_DEBUG("There are applications subscribed: " << subscribed_way_points_apps_list_.size()); if (subscribed_way_points_apps_list_.empty()) { - way_points_data_.reset(); + hmi_way_points_data_.reset(); + mobile_way_points_data_.clear(); } } void ApplicationManagerImpl::UnsubscribeAppFromWayPoints( - ApplicationSharedPtr app) { - UnsubscribeAppFromWayPoints(app->app_id()); + ApplicationSharedPtr app, bool response_from_hmi) { + UnsubscribeAppFromWayPoints(app->app_id(), response_from_hmi); +} + +bool ApplicationManagerImpl::IsSubscribedToHMIWayPoints() const { + SDL_LOG_AUTO_TRACE(); + return subscribed_to_hmi_way_points_; } bool ApplicationManagerImpl::IsAnyAppSubscribedForWayPoints() const { @@ -4772,9 +4862,17 @@ bool ApplicationManagerImpl::IsAnyAppSubscribedForWayPoints() const { } void ApplicationManagerImpl::SaveWayPointsMessage( - std::shared_ptr way_points_message) { + std::shared_ptr way_points_message, + uint32_t app_id) { sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_); - way_points_data_ = way_points_message; + // Notification from HMI + if (0 == app_id) { + hmi_way_points_data_ = way_points_message; + } + // Notification from app service provider + else { + mobile_way_points_data_[app_id] = *way_points_message; + } } const std::set ApplicationManagerImpl::GetAppsSubscribedForWayPoints() @@ -4890,6 +4988,23 @@ bool ApplicationManagerImpl::IsSOStructValid( return false; } +bool ApplicationManagerImpl::UnsubscribeAppFromSoftButtons( + const commands::MessageSharedPtr response) { + using namespace mobile_apis; + + const uint32_t connection_key = + (*response)[strings::params][strings::connection_key].asUInt(); + const auto function_id = static_cast( + (*response)[strings::params][strings::function_id].asInt()); + + ApplicationSharedPtr app = application(connection_key); + DCHECK_OR_RETURN(app, false); + app->UnsubscribeFromSoftButtons(function_id); + SDL_LOG_DEBUG("Application has unsubscribed from softbuttons. FunctionID: " + << function_id << ", app_id:" << app->app_id()); + return true; +} + #ifdef BUILD_TESTS void ApplicationManagerImpl::AddMockApplication(ApplicationSharedPtr mock_app) { applications_list_lock_ptr_->Acquire(); diff --git a/src/components/application_manager/src/display_capabilities_builder.cc b/src/components/application_manager/src/display_capabilities_builder.cc index e0d486ab14a..2988d534717 100644 --- a/src/components/application_manager/src/display_capabilities_builder.cc +++ b/src/components/application_manager/src/display_capabilities_builder.cc @@ -157,7 +157,8 @@ bool DisplayCapabilitiesBuilder::IsWaitingForWindowCapabilities( void DisplayCapabilitiesBuilder::ResetDisplayCapabilities() { SDL_LOG_AUTO_TRACE(); sync_primitives::AutoLock lock(display_capabilities_lock_); - for (auto& window_id : window_ids_to_resume_) { + auto window_ids = window_ids_to_resume_; + for (auto& window_id : window_ids) { if (kDefaultWindowID != window_id) { window_ids_to_resume_.erase(window_id); } diff --git a/src/components/application_manager/src/helpers/application_helper.cc b/src/components/application_manager/src/helpers/application_helper.cc index 488ee4aca0c..74810d7e099 100644 --- a/src/components/application_manager/src/helpers/application_helper.cc +++ b/src/components/application_manager/src/helpers/application_helper.cc @@ -9,19 +9,23 @@ namespace { using namespace application_manager; void DeleteWayPoints(ApplicationSharedPtr app, ApplicationManager& app_manager) { - app_manager.UnsubscribeAppFromWayPoints(app); - if (!app_manager.IsAnyAppSubscribedForWayPoints()) { + std::set subscribed_apps = + app_manager.GetAppsSubscribedForWayPoints(); + bool send_unsubscribe = + subscribed_apps.size() <= 1 && app_manager.IsSubscribedToHMIWayPoints(); + if (send_unsubscribe) { auto request = MessageHelper::CreateUnsubscribeWayPointsRequest( app_manager.GetNextHMICorrelationID()); app_manager.GetRPCService().ManageHMICommand(request); } + app_manager.UnsubscribeAppFromWayPoints(app, send_unsubscribe); } void DeleteCommands(ApplicationSharedPtr app, ApplicationManager& app_manager) { auto accessor = app->commands_map(); - const auto& commands_map = accessor.GetData(); + const auto commands_map = accessor.GetData(); - for (const auto& cmd : commands_map) { + for (const auto cmd : commands_map) { auto delete_UI_msg = MessageHelper::CreateDeleteUICommandRequest( cmd.second, app->app_id(), app_manager.GetNextHMICorrelationID()); app_manager.GetRPCService().ManageHMICommand(delete_UI_msg); @@ -37,9 +41,9 @@ void DeleteCommands(ApplicationSharedPtr app, ApplicationManager& app_manager) { void DeleteSubmenus(ApplicationSharedPtr app, ApplicationManager& app_manager) { auto accessor = app->sub_menu_map(); - const auto& sub_menu_map = accessor.GetData(); + const auto sub_menu_map = accessor.GetData(); - for (const auto& smenu : sub_menu_map) { + for (const auto smenu : sub_menu_map) { MessageHelper::SendDeleteSubmenuRequest(smenu.second, app, app_manager); app->RemoveSubMenu(smenu.first); } @@ -48,9 +52,9 @@ void DeleteSubmenus(ApplicationSharedPtr app, ApplicationManager& app_manager) { void DeleteChoiceSets(ApplicationSharedPtr app, ApplicationManager& app_manager) { auto accessor = app->choice_set_map(); - const auto& choices = accessor.GetData(); + const auto choices = accessor.GetData(); - for (const auto& choice : choices) { + for (const auto choice : choices) { MessageHelper::SendDeleteChoiceSetRequest(choice.second, app, app_manager); app->RemoveChoiceSet(choice.first); } diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index 1390a3ae2c6..f313e0c0a52 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -126,6 +126,13 @@ HMICapabilitiesImpl::HMICapabilitiesImpl(ApplicationManager& app_mngr) is_ivi_cooperating_ = true; is_rc_cooperating_ = true; } + requests_required_for_capabilities_ = { + hmi_apis::FunctionID::VehicleInfo_IsReady, + hmi_apis::FunctionID::VR_IsReady, + hmi_apis::FunctionID::TTS_IsReady, + hmi_apis::FunctionID::UI_IsReady, + hmi_apis::FunctionID::RC_IsReady, + hmi_apis::FunctionID::Navigation_IsReady}; } HMICapabilitiesImpl::~HMICapabilitiesImpl() {} @@ -1860,6 +1867,15 @@ const std::string& HMICapabilitiesImpl::ccpu_version() const { return ccpu_version_; } +void HMICapabilitiesImpl::set_hardware_version( + const std::string& hardware_version) { + hardware_version_ = hardware_version; +} + +const std::string& HMICapabilitiesImpl::hardware_version() const { + return hardware_version_; +} + void HMICapabilitiesImpl::convert_json_languages_to_obj( const Json::Value& json_languages, smart_objects::SmartObject& languages) const { 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 ba1c726415d..b25e07c8f3f 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -53,6 +53,7 @@ #include "application_manager/message_helper.h" #include "application_manager/policies/policy_handler_interface.h" #include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h" #include "application_manager/rpc_service.h" #include "connection_handler/connection_handler_impl.h" #include "interfaces/MOBILE_API.h" @@ -183,6 +184,8 @@ std::pair std::make_pair( strings::cloud_app_vehicle_id, mobile_apis::VehicleDataType::VEHICLEDATA_CLOUDAPPVEHICLEID), + std::make_pair(strings::climate_data, + mobile_apis::VehicleDataType::VEHICLEDATA_CLIMATEDATA), std::make_pair(strings::external_temp, mobile_apis::VehicleDataType::VEHICLEDATA_EXTERNTEMP), std::make_pair(strings::turn_signal, @@ -246,6 +249,8 @@ std::pair mobile_apis::VehicleDataType::VEHICLEDATA_ENGINEOILLIFE), std::make_pair(strings::window_status, mobile_apis::VehicleDataType::VEHICLEDATA_WINDOWSTATUS), + std::make_pair(strings::seat_occupancy, + mobile_apis::VehicleDataType::VEHICLEDATA_SEATOCCUPANCY), std::make_pair( strings::hands_off_steering, mobile_apis::VehicleDataType::VEHICLEDATA_HANDSOFFSTEERING)}; @@ -392,18 +397,23 @@ MessageHelper::CreateUIResetGlobalPropertiesRequest( } if (reset_result.keyboard_properties) { - 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_list] = + keyboard_properties[hmi_request::auto_complete_list] = smart_objects::SmartObject(smart_objects::SmartType_Array); + keyboard_properties[strings::auto_complete_text] = ""; + keyboard_properties[hmi_request::mask_input_characters] = + static_cast( + hmi_apis::Common_KeyboardInputMask::DISABLE_INPUT_KEY_MASK); - key_board_properties[strings::auto_complete_text] = ""; (*ui_reset_global_prop_request)[hmi_request::keyboard_properties] = - key_board_properties; + keyboard_properties; + application->set_keyboard_props( + smart_objects::SmartObject(smart_objects::SmartType_Null)); } (*ui_reset_global_prop_request)[strings::app_id] = application->app_id(); @@ -411,6 +421,39 @@ MessageHelper::CreateUIResetGlobalPropertiesRequest( return ui_reset_global_prop_request; } +smart_objects::SmartObjectSPtr +MessageHelper::CreateRCResetGlobalPropertiesRequest( + const ResetGlobalPropertiesResult& reset_result, + const ApplicationSharedPtr application) { + namespace rc = rc_rpc_plugin; + + smart_objects::SmartObjectSPtr rc_reset_global_prop_request = + std::make_shared( + smart_objects::SmartType_Map); + + if (reset_result.user_location) { + smart_objects::SmartObject user_location = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + user_location[rc::strings::kGrid] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + smart_objects::SmartObject& grid = user_location[rc::strings::kGrid]; + grid[rc::strings::kRow] = 0; + grid[rc::strings::kCol] = 0; + grid[rc::strings::kLevel] = 0; + grid[rc::strings::kRowspan] = 1; + grid[rc::strings::kColspan] = 1; + grid[rc::strings::kLevelspan] = 1; + + (*rc_reset_global_prop_request)[strings::user_location] = user_location; + application->set_user_location(user_location); + } + + (*rc_reset_global_prop_request)[strings::app_id] = application->app_id(); + + return rc_reset_global_prop_request; +} + smart_objects::SmartObjectSPtr MessageHelper::CreateDisplayCapabilityUpdateToMobile( const smart_objects::SmartObject& display_capabilities, Application& app) { @@ -1244,38 +1287,38 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( // UI global properties - if (can_send_ui && (app->vr_help_title() || app->vr_help())) { + if (can_send_ui && + (app->vr_help_title() || app->vr_help() || app->keyboard_props() || + app->menu_title() || app->menu_icon())) { smart_objects::SmartObjectSPtr ui_global_properties = CreateMessageForHMI( hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); - if (!ui_global_properties) { - return requests; - } - - (*ui_global_properties)[strings::params][strings::function_id] = - static_cast(hmi_apis::FunctionID::UI_SetGlobalProperties); + if (ui_global_properties) { + (*ui_global_properties)[strings::params][strings::function_id] = + static_cast(hmi_apis::FunctionID::UI_SetGlobalProperties); - smart_objects::SmartObject ui_msg_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - if (app->vr_help_title()) { - ui_msg_params[strings::vr_help_title] = (*app->vr_help_title()); - } - if (app->vr_help()) { - ui_msg_params[strings::vr_help] = (*app->vr_help()); - } - if (app->keyboard_props()) { - ui_msg_params[strings::keyboard_properties] = (*app->keyboard_props()); - } - if (app->menu_title()) { - ui_msg_params[strings::menu_title] = (*app->menu_title()); - } - if (app->menu_icon()) { - ui_msg_params[strings::menu_icon] = (*app->menu_icon()); - } - ui_msg_params[strings::app_id] = app->app_id(); + smart_objects::SmartObject ui_msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + if (app->vr_help_title()) { + ui_msg_params[strings::vr_help_title] = (*app->vr_help_title()); + } + if (app->vr_help()) { + ui_msg_params[strings::vr_help] = (*app->vr_help()); + } + if (app->keyboard_props()) { + ui_msg_params[strings::keyboard_properties] = (*app->keyboard_props()); + } + if (app->menu_title()) { + ui_msg_params[strings::menu_title] = (*app->menu_title()); + } + if (app->menu_icon()) { + ui_msg_params[strings::menu_icon] = (*app->menu_icon()); + } + ui_msg_params[strings::app_id] = app->app_id(); - (*ui_global_properties)[strings::msg_params] = ui_msg_params; + (*ui_global_properties)[strings::msg_params] = ui_msg_params; - requests.push_back(ui_global_properties); + requests.push_back(ui_global_properties); + } } const bool can_send_vr = helpers:: @@ -1289,27 +1332,46 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI( uint32_t correlation_id = app_mngr.GetNextHMICorrelationID(); smart_objects::SmartObjectSPtr tts_global_properties = CreateMessageForHMI(hmi_apis::messageType::request, correlation_id); - if (!tts_global_properties) { - return requests; - } + if (tts_global_properties) { + (*tts_global_properties)[strings::params][strings::function_id] = + static_cast(hmi_apis::FunctionID::TTS_SetGlobalProperties); - (*tts_global_properties)[strings::params][strings::function_id] = - static_cast(hmi_apis::FunctionID::TTS_SetGlobalProperties); + smart_objects::SmartObject tts_msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + if (app->help_prompt()) { + tts_msg_params[strings::help_prompt] = (*app->help_prompt()); + } + if (app->timeout_prompt()) { + tts_msg_params[strings::timeout_prompt] = (*app->timeout_prompt()); + } + tts_msg_params[strings::app_id] = app->app_id(); - smart_objects::SmartObject tts_msg_params = - smart_objects::SmartObject(smart_objects::SmartType_Map); - if (app->help_prompt()) { - tts_msg_params[strings::help_prompt] = (*app->help_prompt()); - } - if (app->timeout_prompt()) { - tts_msg_params[strings::timeout_prompt] = (*app->timeout_prompt()); + (*tts_global_properties)[strings::msg_params] = tts_msg_params; + + requests.push_back(tts_global_properties); } - tts_msg_params[strings::app_id] = app->app_id(); + } - (*tts_global_properties)[strings::msg_params] = tts_msg_params; + // RC global properties + if (!app->get_user_location().empty()) { + smart_objects::SmartObjectSPtr rc_global_properties = CreateMessageForHMI( + hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID()); + if (rc_global_properties) { + (*rc_global_properties)[strings::params][strings::function_id] = + static_cast(hmi_apis::FunctionID::RC_SetGlobalProperties); + + smart_objects::SmartObject rc_msg_params = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + rc_msg_params[strings::user_location] = (app->get_user_location()); + rc_msg_params[strings::app_id] = app->app_id(); - requests.push_back(tts_global_properties); + (*rc_global_properties)[strings::msg_params] = rc_msg_params; + + requests.push_back(rc_global_properties); + } } + return requests; } @@ -3365,16 +3427,20 @@ void MessageHelper::SubscribeApplicationToSoftButton( ApplicationSharedPtr app, 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) { - 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); + if (!message_params.keyExists(strings::soft_buttons)) { + return; + } + + std::set soft_buttons; + + auto& soft_buttons_so = message_params[strings::soft_buttons]; + for (const auto& softbutton : *(soft_buttons_so.asArray())) { + const auto button_id = softbutton[strings::soft_button_id].asUInt(); + soft_buttons.insert(button_id); + } + + WindowSoftButtons window_buttons{window_id, soft_buttons}; + app->SubscribeToSoftButtons(function_id, window_buttons); } void MessageHelper::SubscribeApplicationToSoftButton( diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index b61a75d7def..bacd4781381 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -600,6 +600,10 @@ void PolicyHandler::OnDeviceConsentChanged(const std::string& device_id, policy_manager->SendNotificationOnPermissionsUpdated(device_id, policy_app_id); + + if (policy_manager->IsPredataPolicy(policy_app_id) && !is_allowed) { + SetHeartBeatTimeout(policy_app_id, (*it_app_list)->app_id()); + } } } } @@ -767,6 +771,23 @@ void PolicyHandler::OnAppPermissionConsentInternal( #endif } +void PolicyHandler::SetHeartBeatTimeout(const std::string& policy_app_id, + const uint32_t app_id) { + SDL_LOG_AUTO_TRACE(); + + const std::shared_ptr policy_manager = LoadPolicyManager(); + POLICY_LIB_CHECK_VOID(policy_manager); + + const uint32_t timeout = policy_manager->HeartBeatTimeout(policy_app_id); + if (0 != timeout) { + SDL_LOG_DEBUG("SetHeartBeatTimeout for " << app_id << " is " << timeout); + application_manager_.connection_handler().SetHeartBeatTimeout(app_id, + timeout); + } else { + SDL_LOG_DEBUG("SetHeartBeatTimeout for " << app_id << " ignored"); + } +} + void policy::PolicyHandler::SetDaysAfterEpoch() { const auto policy_manager = LoadPolicyManager(); POLICY_LIB_CHECK_VOID(policy_manager); @@ -817,7 +838,7 @@ void PolicyHandler::OnSystemRequestReceived() const { } void PolicyHandler::TriggerPTUOnStartupIfRequired() { -#ifdef PROPRIETARY_MODE +#if defined(PROPRIETARY_MODE) || defined(EXTERNAL_PROPRIETARY_MODE) const auto policy_manager = LoadPolicyManager(); POLICY_LIB_CHECK_VOID(policy_manager); policy_manager->TriggerPTUOnStartupIfRequired(); @@ -1076,6 +1097,14 @@ void PolicyHandler::OnGetSystemInfo(const std::string& ccpu_version, policy_manager->SetSystemInfo(ccpu_version, wers_country_code, language); } +void PolicyHandler::OnHardwareVersionReceived( + const std::string& hardware_version) { + SDL_LOG_AUTO_TRACE(); + const auto policy_manager = LoadPolicyManager(); + POLICY_LIB_CHECK_VOID(policy_manager); + policy_manager->SetHardwareVersion(hardware_version); +} + std::string PolicyHandler::GetCCPUVersionFromPT() const { SDL_LOG_AUTO_TRACE(); const auto policy_manager = LoadPolicyManager(); @@ -1083,6 +1112,13 @@ std::string PolicyHandler::GetCCPUVersionFromPT() const { return policy_manager->GetCCPUVersionFromPT(); } +std::string PolicyHandler::GetHardwareVersionFromPT() const { + SDL_LOG_AUTO_TRACE(); + const auto policy_manager = LoadPolicyManager(); + POLICY_LIB_CHECK_OR_RETURN(policy_manager, std::string()); + return policy_manager->GetHardwareVersionFromPT(); +} + void PolicyHandler::OnVIIsReady() { SDL_LOG_AUTO_TRACE(); const uint32_t correlation_id = @@ -1359,7 +1395,6 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification( } #ifdef EXTERNAL_PROPRIETARY_MODE - ApplicationSet applications; { DataAccessor accessor = @@ -1405,7 +1440,6 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification( } #ifdef EXTERNAL_PROPRIETARY_MODE - if (last_activated_app_id_) { ApplicationSharedPtr app = application_manager_.application(last_activated_app_id_); @@ -1416,7 +1450,14 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification( << "' not found among registered applications."); return; } - if (is_allowed) { + + bool is_allowed_by_policies = true; + if (PolicyEnabled()) { + is_allowed_by_policies = + !policy_manager->IsApplicationRevoked(app->policy_app_id()); + } + + if (is_allowed && is_allowed_by_policies) { // Send HMI status notification to mobile // Put application in full AudioStreamingState::eType audio_state = @@ -1489,7 +1530,9 @@ void PolicyHandler::OnActivateApp(uint32_t connection_key, // is not allowed. if (!permissions.isSDLAllowed) { permissions.priority.clear(); - last_activated_app_id_ = connection_key; + if (!permissions.appRevoked) { + last_activated_app_id_ = connection_key; + } } if (permissions.appRevoked) { 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 6a045fda035..bc373d48c9e 100644 --- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc +++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc @@ -514,16 +514,30 @@ void ResumeCtrlImpl::StartAppHmiStateResumption( const bool is_resume_allowed_by_low_voltage = CheckLowVoltageRestrictions(saved_app); - const bool is_hmi_level_allowed_by_ign_cycle = - CheckIgnCycleRestrictions(saved_app); - + const time_t sdl_launch_time = LaunchTime(); + const bool is_unexpected_disconnect_in_current_ign_cycle = + sdl_launch_time < saved_app[strings::time_stamp].asInt(); + SDL_LOG_DEBUG("sdl_launch_time: " << sdl_launch_time + << ", App disconnect time: " + << saved_app[strings::time_stamp].asInt()); const bool is_app_revoked = application_manager_.GetPolicyHandler().IsApplicationRevoked( application->policy_app_id()); - const bool restore_hmi_level_allowed = is_resume_allowed_by_low_voltage && - is_hmi_level_allowed_by_ign_cycle && - !is_app_revoked; + bool restore_hmi_level_allowed = true; + if (!is_unexpected_disconnect_in_current_ign_cycle) { + const bool is_hmi_level_allowed_by_ign_cycle = + CheckIgnCycleRestrictions(saved_app); + restore_hmi_level_allowed = is_resume_allowed_by_low_voltage && + is_hmi_level_allowed_by_ign_cycle && + !is_app_revoked; + } else { + const bool is_resume_app_data_not_expired = + !IsAppDataResumptionExpired(saved_app); + restore_hmi_level_allowed = is_resume_allowed_by_low_voltage && + is_resume_app_data_not_expired && + !is_app_revoked; + } if (restore_hmi_level_allowed) { SDL_LOG_INFO("Resume application " << application->policy_app_id()); 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 f00b100913e..eedfc48b732 100644 --- a/src/components/application_manager/src/resumption/resumption_data_db.cc +++ b/src/components/application_manager/src/resumption/resumption_data_db.cc @@ -37,6 +37,7 @@ #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/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h" #include "application_manager/smart_object_keys.h" #include "utils/gen_hash.h" #include "utils/helpers.h" @@ -326,6 +327,12 @@ bool ResumptionDataDB::GetSavedApplication( SDL_LOG_ERROR("Problem with restoring of global properties data"); return false; } + + if (!SelectUserLocationData(policy_app_id, device_id, saved_app)) { + SDL_LOG_ERROR("Problem with restoring of user location data"); + return false; + } + SDL_LOG_INFO("Application data were successfully fetched from data base"); return true; } @@ -762,6 +769,9 @@ bool ResumptionDataDB::DropAppDataResumption(const std::string& device_id, if (!DeleteSavedGlobalProperties(app_id, device_id)) { return false; } + if (!DeleteUserLocation(app_id, device_id)) { + return false; + } if (!UpdateGrammarID(app_id, device_id, 0)) { return false; } @@ -1006,6 +1016,58 @@ bool ResumptionDataDB::SelectSubscriptionsData( return true; } +bool ResumptionDataDB::SelectUserLocationData( + const std::string& policy_app_id, + const std::string& device_id, + smart_objects::SmartObject& saved_app) const { + SDL_LOG_AUTO_TRACE(); + using namespace app_mngr; + using namespace smart_objects; + uint32_t count_item = 0; + if (!SelectCountFromArray( + count_item, kSelectCountUserLocation, policy_app_id, device_id)) { + SDL_LOG_ERROR("Select query has been failed"); + return false; + } + + if (0 == count_item) { + SDL_LOG_DEBUG("Application does not contain user_location data"); + return true; + } + utils::dbms::SQLQuery select_user_location(db()); + if (!PrepareSelectQuery(select_user_location, + policy_app_id, + device_id, + kSelectUserLocation)) { + SDL_LOG_ERROR("Failed to prepare user location select query"); + return false; + } + + if (!select_user_location.Exec()) { + SDL_LOG_ERROR("Failed to execute user location select query"); + return false; + } + /* Position of data in "select_user_location" : + field "col" from table "applicationUserLocation" = 0 + field "colspan" from table "applicationUserLocation" = 1 + field "level" from table "applicationUserLocation" = 2 + field "levelspan" from table "applicationUserLocation" = 3 + field "row" from table "applicationUserLocation" = 4 + field "rowspan" from table "applicationUserLocation" = 5*/ + smart_objects::SmartObject grid = + smart_objects::SmartObject(smart_objects::SmartType_Map); + grid[rc_rpc_plugin::strings::kCol] = select_user_location.GetInteger(0); + grid[rc_rpc_plugin::strings::kColspan] = select_user_location.GetInteger(1); + grid[rc_rpc_plugin::strings::kLevel] = select_user_location.GetInteger(2); + grid[rc_rpc_plugin::strings::kLevelspan] = select_user_location.GetInteger(3); + grid[rc_rpc_plugin::strings::kRow] = select_user_location.GetInteger(4); + grid[rc_rpc_plugin::strings::kRowspan] = select_user_location.GetInteger(5); + + saved_app[strings::user_location][rc_rpc_plugin::strings::kGrid] = grid; + + return true; +} + bool ResumptionDataDB::SelectChoiceSetData( const std::string& policy_app_id, const std::string& device_id, @@ -1519,6 +1581,18 @@ bool ResumptionDataDB::DeleteSavedSubscriptions( return true; } +bool ResumptionDataDB::DeleteUserLocation(const std::string& policy_app_id, + const std::string& device_id) { + SDL_LOG_AUTO_TRACE(); + + if (!ExecQueryToDeleteData( + policy_app_id, device_id, kDeleteApplicationUserLocation)) { + SDL_LOG_WARN("Incorrect delete from applicationUserLocation."); + return false; + } + return true; +} + bool ResumptionDataDB::DeleteSavedCommands(const std::string& policy_app_id, const std::string& device_id) { SDL_LOG_AUTO_TRACE(); @@ -1914,6 +1988,12 @@ bool ResumptionDataDB::SaveApplicationToDB( db_->RollbackTransaction(); return false; } + if (!InsertUserLocationData(application->get_user_location(), + application_primary_key)) { + SDL_LOG_WARN("Incorrect insert user location to DB."); + db_->RollbackTransaction(); + return false; + } db_->CommitTransaction(); return true; } @@ -1973,6 +2053,12 @@ bool ResumptionDataDB::SaveApplicationToDB( db_->RollbackTransaction(); return false; } + if (!InsertUserLocationData(application["userLocation"], + application_primary_key)) { + SDL_LOG_WARN("Incorrect insert userLocation to DB."); + db_->RollbackTransaction(); + return false; + } db_->CommitTransaction(); return true; } @@ -2222,6 +2308,58 @@ bool ResumptionDataDB::InsertChoiceSetData( return true; } +bool ResumptionDataDB::InsertUserLocationData( + const smart_objects::SmartObject& user_location, + int64_t application_primary_key) const { + SDL_LOG_AUTO_TRACE(); + using namespace app_mngr; + using namespace smart_objects; + + if (user_location.empty()) { + SDL_LOG_DEBUG("Application doesn't contain user location"); + return true; + } + + const auto grid = user_location[rc_rpc_plugin::strings::kGrid]; + const int32_t col = grid[rc_rpc_plugin::strings::kCol].asInt(); + const int32_t row = grid[rc_rpc_plugin::strings::kRow].asInt(); + const int32_t level = grid[rc_rpc_plugin::strings::kLevel].asInt(); + const int32_t colspan = grid[rc_rpc_plugin::strings::kColspan].asInt(); + const int32_t rowspan = grid[rc_rpc_plugin::strings::kRowspan].asInt(); + const int32_t levelspan = grid[rc_rpc_plugin::strings::kLevelspan].asInt(); + + utils::dbms::SQLQuery insert_application_user_location(db()); + if (!insert_application_user_location.Prepare(kInsertUserLocation)) { + SDL_LOG_WARN( + "Problem with preparation insert " + "application user location query"); + return false; + } + + /* Positions of binding data for "insert_application_user_location": + field "idApplication" from table "applicationUserLocation" = 0 + field "col" from table "applicationUserLocation" = 1 + field "colspan" from table "applicationUserLocation" = 2 + field "level" from table "applicationUserLocation" = 3 + field "levelspan" from table "applicationUserLocation" = 4 + field "row" from table "applicationUserLocation" = 5 + field "rowspan" from table "applicationUserLocation" = 6*/ + insert_application_user_location.Bind(0, application_primary_key); + insert_application_user_location.Bind(1, col); + insert_application_user_location.Bind(2, colspan); + insert_application_user_location.Bind(3, level); + insert_application_user_location.Bind(4, levelspan); + insert_application_user_location.Bind(5, row); + insert_application_user_location.Bind(6, rowspan); + + if (!insert_application_user_location.Exec()) { + SDL_LOG_WARN("Incorrect insertion of user location"); + return false; + } + + return true; +} + bool ResumptionDataDB::ExecInsertApplicationChoiceSet( int64_t& choice_set_primary_key, const smart_objects::SmartObject& choiceset) const { 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 f3d417d128b..1f2d0f116f6 100644 --- a/src/components/application_manager/src/resumption/resumption_data_json.cc +++ b/src/components/application_manager/src/resumption/resumption_data_json.cc @@ -107,6 +107,9 @@ void ResumptionDataJson::SaveApplication( 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; + formatters::CFormatterJsonBase::objToJsonValue( + application->get_user_location(), tmp); + json_app[strings::user_location] = tmp; accessor.GetMutableData().set_dictionary(dictionary); SDL_LOG_DEBUG("SaveApplication : " << json_app.toStyledString()); @@ -557,6 +560,7 @@ bool ResumptionDataJson::DropAppDataResumption(const std::string& device_id, application[strings::application_global_properties].clear(); application[strings::application_subscriptions].clear(); application[strings::application_files].clear(); + application[strings::user_location].clear(); application.removeMember(strings::grammar_id); accessor.GetMutableData().set_dictionary(dictionary); SDL_LOG_DEBUG("Resumption data for application " diff --git a/src/components/application_manager/src/resumption/resumption_data_processor_impl.cc b/src/components/application_manager/src/resumption/resumption_data_processor_impl.cc index 792e7f97eac..dffb1ea094e 100644 --- a/src/components/application_manager/src/resumption/resumption_data_processor_impl.cc +++ b/src/components/application_manager/src/resumption/resumption_data_processor_impl.cc @@ -29,6 +29,7 @@ #include "application_manager/application_manager.h" #include "application_manager/commands/command_impl.h" +#include "application_manager/commands/command_request_impl.h" #include "application_manager/display_capabilities_builder.h" #include "application_manager/event_engine/event_observer.h" #include "application_manager/message_helper.h" @@ -151,6 +152,8 @@ void ResumptionDataProcessorImpl::ProcessResumptionStatus( if (IsResponseSuccessful(response)) { status.successful_requests.push_back(found_request); } else { + SDL_LOG_DEBUG("Resumption request failed"); + MessageHelper::PrintSmartObject(response); status.error_requests.push_back(found_request); } @@ -534,9 +537,9 @@ void ResumptionDataProcessorImpl::DeleteSubmenus( application->app_id(), resumption_status_, resumption_status_lock_); auto accessor = application->sub_menu_map(); - const auto& sub_menu_map = accessor.GetData(); + const auto sub_menu_map = accessor.GetData(); - for (const auto& smenu : sub_menu_map) { + for (const auto smenu : sub_menu_map) { auto failed_submenu_request = FindResumptionSubmenuRequest(smenu.first, failed_requests); if (!failed_submenu_request) { @@ -627,9 +630,9 @@ void ResumptionDataProcessorImpl::DeleteCommands( }; auto accessor = application->commands_map(); - const auto& commands_map = accessor.GetData(); + const auto commands_map = accessor.GetData(); - for (const auto& cmd : commands_map) { + for (const auto cmd : commands_map) { const auto cmd_id = extract_cmd_id(cmd.second); if (0 == cmd_id) { SDL_LOG_ERROR("Can't extract cmd_id for command with internal number: " @@ -719,8 +722,8 @@ void ResumptionDataProcessorImpl::DeleteChoicesets( application->app_id(), resumption_status_, resumption_status_lock_); auto accessor = application->choice_set_map(); - const auto& choices = accessor.GetData(); - for (const auto& choice : choices) { + const auto choices = accessor.GetData(); + for (const auto choice : choices) { auto failed_choice_set = FindResumptionChoiceSetRequest(choice.first, failed_requests); if (!failed_choice_set) { @@ -744,6 +747,10 @@ void ResumptionDataProcessorImpl::SetGlobalProperties( saved_app[strings::application_global_properties]; application->load_global_properties(properties_so); + if (saved_app.keyExists(strings::user_location)) { + application->set_user_location(saved_app[strings::user_location]); + } + ProcessMessagesToHMI(MessageHelper::CreateGlobalPropertiesRequestsToHMI( application, application_manager_)); } @@ -803,6 +810,21 @@ void ResumptionDataProcessorImpl::DeleteGlobalProperties( (*msg)[strings::msg_params] = *msg_params; ProcessMessageToHMI(msg, false); } + + if (result.HasRCPropertiesReset() && + check_if_successful(hmi_apis::FunctionID::RC_SetGlobalProperties)) { + smart_objects::SmartObjectSPtr msg_params = + MessageHelper::CreateRCResetGlobalPropertiesRequest(result, + application); + auto msg = MessageHelper::CreateMessageForHMI( + hmi_apis::messageType::request, + application_manager_.GetNextHMICorrelationID()); + (*msg)[strings::params][strings::function_id] = + hmi_apis::FunctionID::RC_SetGlobalProperties; + + (*msg)[strings::msg_params] = *msg_params; + ProcessMessageToHMI(msg, false); + } } void ResumptionDataProcessorImpl::AddSubscriptions( @@ -881,7 +903,7 @@ void ResumptionDataProcessorImpl::DeleteButtonsSubscriptions( SDL_LOG_AUTO_TRACE(); const ButtonSubscriptions button_subscriptions = application->SubscribedButtons().GetData(); - for (auto& btn : button_subscriptions) { + for (auto btn : button_subscriptions) { const auto hmi_btn = static_cast(btn); if (hmi_apis::Common_ButtonName::CUSTOM_BUTTON == hmi_btn) { continue; @@ -973,7 +995,12 @@ void ResumptionDataProcessorImpl::DeletePluginsSubscriptions( } bool IsResponseSuccessful(const smart_objects::SmartObject& response) { - return !response[strings::params].keyExists(strings::error_msg); + auto result_code = static_cast( + response[strings::params][application_manager::hmi_response::code] + .asInt()); + + return commands::CommandRequestImpl::IsHMIResultSuccess(result_code) || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == result_code; } void ResumptionDataProcessorImpl::CheckVehicleDataResponse( @@ -1079,8 +1106,6 @@ void ResumptionDataProcessorImpl::CheckCreateWindowResponse( const smart_objects::SmartObject& request, const smart_objects::SmartObject& response) const { SDL_LOG_AUTO_TRACE(); - const auto correlation_id = - response[strings::params][strings::correlation_id].asInt(); const auto& msg_params = request[strings::msg_params]; const auto app_id = msg_params[strings::app_id].asInt(); @@ -1093,8 +1118,9 @@ void ResumptionDataProcessorImpl::CheckCreateWindowResponse( const auto window_id = msg_params[strings::window_id].asInt(); if (!IsResponseSuccessful(response)) { - SDL_LOG_ERROR("UI_CreateWindow for correlation id: " << correlation_id - << " has failed"); + SDL_LOG_ERROR("UI_CreateWindow for correlation id: " + << response[strings::params][strings::correlation_id].asInt() + << " has failed"); auto& builder = application->display_capabilities_builder(); builder.ResetDisplayCapabilities(); return; diff --git a/src/components/application_manager/src/resumption/resumption_sql_queries.cc b/src/components/application_manager/src/resumption/resumption_sql_queries.cc index 4770bafef4e..cfcac136aa9 100644 --- a/src/components/application_manager/src/resumption/resumption_sql_queries.cc +++ b/src/components/application_manager/src/resumption/resumption_sql_queries.cc @@ -314,6 +314,23 @@ const std::string kCreateSchema = "CREATE TABLE IF NOT EXISTS `_internal_data`( " " `db_version_hash` INTEGER " " ); " + "CREATE TABLE IF NOT EXISTS `applicationUserLocation`( " + " `idLocation` INTEGER PRIMARY KEY NOT NULL, " + " `idApplication` INTEGER, " + " `col` INTEGER, " + " `colspan` INTEGER, " + " `level` INTEGER, " + " `levelspan` INTEGER, " + " `row` INTEGER, " + " `rowspan` INTEGER, " + " CONSTRAINT `fk_Application` " + " FOREIGN KEY(`idApplication`) " + " REFERENCES `application`(`idApplication`) " + " ); " + "CREATE INDEX IF NOT EXISTS " + "`applicationUserLocation.fk_Application_idx` " + " ON `applicationUserLocation`(`idApplication`); " + "COMMIT;"; const std::string kDropSchema = @@ -369,6 +386,8 @@ const std::string kDropSchema = "DROP TABLE IF EXISTS `applicationSubscriptionsArray`; " "DROP INDEX IF EXISTS `applicationSubscriptionsArray.fk_Application_idx`; " "DROP TABLE IF EXISTS `_internal_data`; " + "DROP TABLE IF EXISTS `applicationUserLocation`; " + "DROP INDEX IF EXISTS `applicationUserLocation.fk_Application_idx`; " "COMMIT; " "VACUUM;"; @@ -497,6 +516,12 @@ const std::string kDeleteApplicationSubscriptionsArray = "FROM `application` " "WHERE `appID` = ? AND `deviceID` = ?)"; +const std::string kDeleteApplicationUserLocation = + "DELETE FROM `applicationUserLocation` " + "WHERE `idApplication` = (SELECT `idApplication` " + "FROM `application` " + "WHERE `appID` = ? AND `deviceID` = ?)"; + const std::string kDeleteImageFromCommands = "DELETE FROM `image` " "WHERE `idimage` IN (SELECT `idimage` " @@ -732,6 +757,13 @@ const std::string kInsertSubscriptions = "VALUES " "(?, ?, ?);"; +const std::string kInsertUserLocation = + "INSERT INTO `applicationUserLocation` " + "(`idApplication`, `col`, `colspan`, `level`, `levelspan`, `row`, " + "`rowspan`) " + "VALUES " + "(?, ?, ?, ?, ?, ?, ?);"; + const std::string kInsertChoice = "INSERT INTO `choice` " "(`choiceID`, `menuName`, `secondaryText`, " @@ -877,6 +909,18 @@ const std::string kSelectSubscriptions = "FROM `application` " "WHERE `appID` = ? AND `deviceID` = ?);"; +const std::string kSelectCountUserLocation = + "SELECT COUNT (*) " + "FROM `applicationUserLocation` INNER JOIN `application` ON " + "`applicationUserLocation`.`idApplication` = `application`.`idApplication` " + "WHERE `appID` = ? AND `deviceID` = ?"; + +const std::string kSelectUserLocation = + "SELECT `col`, `colspan`, `level`, `levelspan`, `row`, `rowspan` " + "FROM `applicationUserLocation` INNER JOIN `application` ON " + "`applicationUserLocation`.`idApplication` = `application`.`idApplication` " + "WHERE `appID` = ? AND `deviceID` = ?"; + const std::string kSelectCountChoiceSet = "SELECT COUNT (`idApplication`) " "FROM `applicationChoiceSetArray` " diff --git a/src/components/application_manager/src/rpc_handler_impl.cc b/src/components/application_manager/src/rpc_handler_impl.cc index 4137ab93bb0..b6b9f2e16b9 100644 --- a/src/components/application_manager/src/rpc_handler_impl.cc +++ b/src/components/application_manager/src/rpc_handler_impl.cc @@ -466,8 +466,6 @@ bool RPCHandlerImpl::ConvertMessageToSO( break; } case protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_1: { - static ns_smart_device_link_rpc::V1::v4_protocol_v1_2_no_extra v1_shema; - if (message.function_id() == 0 || message.type() == kUnknownType) { SDL_LOG_ERROR("Message received: UNSUPPORTED_VERSION"); @@ -495,7 +493,8 @@ bool RPCHandlerImpl::ConvertMessageToSO( smart_objects::SmartObjectSPtr msg_to_send = std::make_shared(output); - v1_shema.attachSchema(*msg_to_send, false); + app_manager_.mobile_v4_protocol_so_factory().attachSchema( + *msg_to_send, false); app_manager_.GetRPCService().SendMessageToMobile(msg_to_send); return false; } @@ -601,5 +600,6 @@ 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_service_impl.cc b/src/components/application_manager/src/rpc_service_impl.cc index 34a0bed7af9..f0cd720e30c 100644 --- a/src/components/application_manager/src/rpc_service_impl.cc +++ b/src/components/application_manager/src/rpc_service_impl.cc @@ -390,7 +390,10 @@ bool RPCServiceImpl::ManageHMICommand(const commands::MessageSharedPtr message, if (command->Init()) { command->Run(); - if (kResponse == message_type) { + if (helpers::Compare( + message_type, kResponse, kErrorResponse) && + message->getElement(strings::params) + .keyExists(strings::correlation_id)) { const uint32_t correlation_id = (*(message.get()))[strings::params][strings::correlation_id].asUInt(); const int32_t function_id = diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index f95476b7a6d..a680653d6cd 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -138,6 +138,9 @@ const char* minutes = "minutes"; const char* seconds = "seconds"; const char* update_mode = "updateMode"; const char* audioStreamingIndicator = "audioStreamingIndicator"; +const char* seek_time = "seekTime"; +const char* forward_seek_indicator = "forwardSeekIndicator"; +const char* back_seek_indicator = "backSeekIndicator"; const char* trigger_source = "triggerSource"; const char* hmi_level = "hmiLevel"; const char* activate_app_hmi_level = "level"; @@ -194,6 +197,8 @@ const char* policy_type = "policyType"; const char* property = "property"; const char* displays = "displays"; const char* seat_location = "seatLocation"; +const char* app_capability = "appCapability"; +const char* app_capability_type = "appCapabilityType"; // PutFile const char* sync_file_name = "syncFileName"; @@ -263,6 +268,7 @@ const char* fuel_level_state = "fuelLevel_State"; const char* instant_fuel_consumption = "instantFuelConsumption"; const char* fuel_range = "fuelRange"; const char* cloud_app_vehicle_id = "cloudAppVehicleID"; +const char* climate_data = "climateData"; const char* external_temp = "externalTemperature"; const char* turn_signal = "turnSignal"; const char* vin = "vin"; @@ -303,11 +309,13 @@ const char* video_streaming = "videoStreaming"; const char* remote_control = "remoteControl"; const char* sdl_version = "sdlVersion"; const char* system_software_version = "systemSoftwareVersion"; +const char* system_hardware_version = "systemHardwareVersion"; const char* priority = "priority"; const char* engine_oil_life = "engineOilLife"; const char* oem_custom_data_type = "oemCustomDataType"; const char* window_status = "windowStatus"; const char* hands_off_steering = "handsOffSteering"; +const char* seat_occupancy = "seatOccupancy"; // app services const char* app_service_manifest = "appServiceManifest"; @@ -439,10 +447,13 @@ 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 additional_video_streaming_capabilities = + "additionalVideoStreamingCapabilities"; const char* const haptic_rect_data = "hapticRectData"; const char* const rect = "rect"; const char* const x = "x"; const char* const y = "y"; +const char* const preferred_fps = "preferredFPS"; } // namespace strings namespace hmi_interface { @@ -541,6 +552,8 @@ const char* method_name = "methodName"; const char* keyboard_layout = "keyboardLayout"; const char* limited_character_list = "limitedCharacterList"; const char* auto_complete_list = "autoCompleteList"; +const char* mask_input_characters = "maskInputCharacters"; +const char* custom_keys = "customKeys"; const char* file = "file"; const char* file_name = "fileName"; const char* retry = "retry"; @@ -578,6 +591,9 @@ const char* image_capabilities = "imageCapabilities"; const char* display_type = "displayType"; const char* display_name = "displayName"; const char* text_fields = "textFields"; +const char* keyboard_capabilities = "keyboardCapabilities"; +const char* supported_keyboards = "supportedKeyboards"; +const char* num_configurable_keys = "numConfigurableKeys"; const char* media_clock_formats = "mediaClockFormats"; const char* graphic_supported = "graphicSupported"; const char* image_fields = "imageFields"; diff --git a/src/components/application_manager/test/CMakeLists.txt b/src/components/application_manager/test/CMakeLists.txt index c9c9a80391f..7b1a262f1b8 100755 --- a/src/components/application_manager/test/CMakeLists.txt +++ b/src/components/application_manager/test/CMakeLists.txt @@ -130,8 +130,8 @@ if (ENABLE_LOG) list(APPEND LIBRARIES expat -L${EXPAT_LIBS_DIRECTORY}) endif() +file(COPY ${CMAKE_SOURCE_DIR}/src/appMain/sdl_preloaded_pt.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY smartDeviceLink_test2.ini DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) -file(COPY sdl_preloaded_pt.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY sdl_pt_update.json DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) add_custom_command( 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 08868a239f3..41d300cc4a3 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 @@ -202,7 +202,7 @@ TEST_F(AppLaunchCtrlTest, StoredAppIsLaunchedAfterDeviceConnected) { app_launch::ApplicationDataPtr app_to_launch = GetTestAppData(0); MockAppPtr app = GetTestApp(0); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); applications_on_device.push_back(app_to_launch); EXPECT_CALL(app_launch_data_mock_, GetApplicationDataByDevice(app_to_launch->device_mac_)) @@ -212,11 +212,11 @@ TEST_F(AppLaunchCtrlTest, StoredAppIsLaunchedAfterDeviceConnected) { RunAppOnDevice(app_to_launch->device_mac_, app_to_launch->bundle_id_)) .Times(AtLeast(1)) .WillOnce(DoAll(InvokeOnAppRegistered(app_launch_ctrl_.get(), app.get()), - NotifyTestAsyncWaiter(&waiter))); + NotifyTestAsyncWaiter(waiter))); app_launch_ctrl_->OnDeviceConnected(app_to_launch->device_mac_); const uint32_t wait_time = MAX_TEST_DURATION + settings_.app_launch_wait_time(); - EXPECT_TRUE(waiter.WaitFor(1, wait_time)); + EXPECT_TRUE(waiter->WaitFor(1, wait_time)); } TEST_F(AppLaunchCtrlTest, RelaunchAppIfNotRegisteredMultipleTimes) { @@ -224,7 +224,7 @@ TEST_F(AppLaunchCtrlTest, RelaunchAppIfNotRegisteredMultipleTimes) { app_launch::ApplicationDataPtr app_to_launch = GetTestAppData(0); applications_on_device.push_back(app_to_launch); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); const uint32_t times = settings_.app_launch_max_retry_attempt(); EXPECT_CALL(app_launch_data_mock_, GetApplicationDataByDevice(app_to_launch->device_mac_)) @@ -234,14 +234,14 @@ TEST_F(AppLaunchCtrlTest, RelaunchAppIfNotRegisteredMultipleTimes) { connection_handler_mock_, RunAppOnDevice(app_to_launch->device_mac_, app_to_launch->bundle_id_)) .Times(times) - .WillRepeatedly(NotifyTestAsyncWaiter(&waiter)); + .WillRepeatedly(NotifyTestAsyncWaiter(waiter)); app_launch_ctrl_->OnDeviceConnected(app_to_launch->device_mac_); const uint32_t wait_time = MAX_TEST_DURATION + settings_.app_launch_wait_time() + settings_.app_launch_max_retry_attempt() * settings_.app_launch_retry_wait_time(); - EXPECT_TRUE(waiter.WaitFor(times, wait_time)); + EXPECT_TRUE(waiter->WaitFor(times, wait_time)); } TEST_F(AppLaunchCtrlTest, LaunchMultipleApps) { @@ -253,7 +253,7 @@ TEST_F(AppLaunchCtrlTest, LaunchMultipleApps) { apps.push_back(it->second); } - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); const uint32_t times = apps_and_data.size(); EXPECT_CALL(app_launch_data_mock_, GetApplicationDataByDevice(DeviceMac(1))) .WillOnce(Return(apps)); @@ -267,13 +267,13 @@ TEST_F(AppLaunchCtrlTest, LaunchMultipleApps) { .Times(AtLeast(1)) .WillOnce(DoAll( InvokeOnAppRegistered(app_launch_ctrl_.get(), it->first.get()), - NotifyTestAsyncWaiter(&waiter))); + NotifyTestAsyncWaiter(waiter))); } app_launch_ctrl_->OnDeviceConnected(DeviceMac(1)); const uint32_t wait_time = MAX_TEST_DURATION + settings_.app_launch_wait_time() + apps.size() * settings_.wait_time_between_apps(); - waiter.WaitFor(times, wait_time); + waiter->WaitFor(times, wait_time); } TEST_F(AppLaunchCtrlTest, LaunchMultipleAppsNoRegister) { @@ -285,7 +285,7 @@ TEST_F(AppLaunchCtrlTest, LaunchMultipleAppsNoRegister) { apps.push_back(it->second); } - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); const uint32_t times = settings_.app_launch_max_retry_attempt() * apps_and_data.size(); EXPECT_CALL(app_launch_data_mock_, GetApplicationDataByDevice(DeviceMac(1))) @@ -300,13 +300,13 @@ TEST_F(AppLaunchCtrlTest, LaunchMultipleAppsNoRegister) { RunAppOnDevice(app_data.second->device_mac_, app_data.second->bundle_id_)) .Times(settings_.app_launch_max_retry_attempt()) - .WillRepeatedly(NotifyTestAsyncWaiter(&waiter)); + .WillRepeatedly(NotifyTestAsyncWaiter(waiter)); } app_launch_ctrl_->OnDeviceConnected(DeviceMac(1)); const uint32_t wait_time = MAX_TEST_DURATION + settings_.app_launch_wait_time() + apps.size() * settings_.wait_time_between_apps(); - waiter.WaitFor(times, wait_time); + waiter->WaitFor(times, wait_time); } TEST_F(AppLaunchCtrlTest, LaunchMultipleAppsInHMILevelOrder) { @@ -343,7 +343,7 @@ TEST_F(AppLaunchCtrlTest, LaunchMultipleAppsInHMILevelOrder) { apps.push_back(app_data); } - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); const uint32_t times = apps_and_data.size(); EXPECT_CALL(app_launch_data_mock_, GetApplicationDataByDevice(DeviceMac(1))) .WillOnce(Return(apps)); @@ -356,7 +356,7 @@ TEST_F(AppLaunchCtrlTest, LaunchMultipleAppsInHMILevelOrder) { .Times(AtLeast(1)) .WillRepeatedly(DoAll( InvokeOnAppRegistered(app_launch_ctrl_.get(), it->first.get()), - NotifyTestAsyncWaiter(&waiter))); + NotifyTestAsyncWaiter(waiter))); } app_launch_ctrl_->OnDeviceConnected(DeviceMac(1)); @@ -364,7 +364,7 @@ TEST_F(AppLaunchCtrlTest, LaunchMultipleAppsInHMILevelOrder) { const uint32_t wait_time = MAX_TEST_DURATION + settings_.app_launch_wait_time() + apps.size() * settings_.wait_time_between_apps(); - waiter.WaitFor(times, wait_time); + waiter->WaitFor(times, wait_time); } } // namespace app_launch_test diff --git a/src/components/application_manager/test/application_helper_test.cc b/src/components/application_manager/test/application_helper_test.cc index 4c451ab0727..1633b9d29bc 100644 --- a/src/components/application_manager/test/application_helper_test.cc +++ b/src/components/application_manager/test/application_helper_test.cc @@ -209,9 +209,6 @@ TEST_F(ApplicationHelperTest, RecallApplicationData_ExpectAppDataReset) { EXPECT_TRUE(NULL != file_ptr); EXPECT_TRUE(file_ptr->file_name == filename); - EXPECT_CALL(*mock_message_helper_, CreateUnsubscribeWayPointsRequest(_)) - .WillOnce(Return(std::make_shared())); - EXPECT_CALL(*mock_message_helper_, CreateDeleteUICommandRequest(_, _, _)) .WillOnce(Return(std::make_shared())); @@ -261,9 +258,6 @@ TEST_F(ApplicationHelperTest, RecallApplicationData_ExpectHMICleanupRequests) { app_impl_->AddChoiceSet(choice_set_id, cmd[strings::msg_params]); app_impl_->SubscribeToButton(mobile_apis::ButtonName::AC); - EXPECT_CALL(*mock_message_helper_, CreateUnsubscribeWayPointsRequest(_)) - .WillOnce(Return(std::make_shared())); - EXPECT_CALL(*mock_message_helper_, CreateDeleteUICommandRequest(_, _, _)) .WillOnce(Return(std::make_shared())); diff --git a/src/components/application_manager/test/application_impl_test.cc b/src/components/application_manager/test/application_impl_test.cc index d468c9790b5..5f23e973912 100644 --- a/src/components/application_manager/test/application_impl_test.cc +++ b/src/components/application_manager/test/application_impl_test.cc @@ -571,14 +571,17 @@ TEST_F(ApplicationImplTest, SubscribeToSoftButton_UnsubscribeFromSoftButton) { EXPECT_FALSE(app_impl->IsSubscribedToSoftButton(i)); } - SoftButtonID test_button; + std::set softbuttons_ids; + for (uint i = 0; i < btn_count; i++) { - test_button.insert(std::make_pair( - i, - static_cast(mobile_apis::PredefinedWindows::DEFAULT_WINDOW))); + softbuttons_ids.insert(i); } + + WindowSoftButtons window_softbuttons{ + static_cast(mobile_apis::PredefinedWindows::DEFAULT_WINDOW), + softbuttons_ids}; app_impl->SubscribeToSoftButtons(FunctionID::ScrollableMessageID, - test_button); + window_softbuttons); for (uint i = 0; i < btn_count; i++) { EXPECT_TRUE(app_impl->IsSubscribedToSoftButton(i)); @@ -837,6 +840,7 @@ TEST_F(ApplicationImplTest, StartStreaming_StreamingApproved) { TEST_F(ApplicationImplTest, SuspendNaviStreaming) { protocol_handler::ServiceType type = protocol_handler::ServiceType::kMobileNav; + EXPECT_CALL(mock_application_manager_, OnAppStreaming(app_id, type, false)); EXPECT_CALL(mock_application_manager_, ProcessOnDataStreamingNotification(type, app_id, false)); app_impl->SuspendStreaming(type); @@ -844,6 +848,7 @@ TEST_F(ApplicationImplTest, SuspendNaviStreaming) { TEST_F(ApplicationImplTest, SuspendAudioStreaming) { protocol_handler::ServiceType type = protocol_handler::ServiceType::kAudio; + EXPECT_CALL(mock_application_manager_, OnAppStreaming(app_id, type, false)); EXPECT_CALL(mock_application_manager_, ProcessOnDataStreamingNotification(type, app_id, false)); app_impl->SuspendStreaming(type); @@ -852,16 +857,12 @@ TEST_F(ApplicationImplTest, SuspendAudioStreaming) { // TODO {AKozoriz} : Fix tests with streaming (APPLINK-19289) TEST_F(ApplicationImplTest, DISABLED_Suspend_WakeUpAudioStreaming) { protocol_handler::ServiceType type = protocol_handler::ServiceType::kAudio; - EXPECT_CALL( - mock_application_manager_, - OnAppStreaming(app_id, type, Application::StreamingState::kSuspended)); + EXPECT_CALL(mock_application_manager_, OnAppStreaming(app_id, type, false)); EXPECT_CALL(*MockMessageHelper::message_helper_mock(), SendOnDataStreaming(type, false, _)); app_impl->SuspendStreaming(type); - EXPECT_CALL( - mock_application_manager_, - OnAppStreaming(app_id, type, Application::StreamingState::kStarted)); + EXPECT_CALL(mock_application_manager_, OnAppStreaming(app_id, type, true)); EXPECT_CALL(*MockMessageHelper::message_helper_mock(), SendOnDataStreaming(type, true, _)); app_impl->WakeUpStreaming(type); @@ -870,16 +871,12 @@ TEST_F(ApplicationImplTest, DISABLED_Suspend_WakeUpAudioStreaming) { TEST_F(ApplicationImplTest, DISABLED_Suspend_WakeUpNaviStreaming) { protocol_handler::ServiceType type = protocol_handler::ServiceType::kMobileNav; - EXPECT_CALL( - mock_application_manager_, - OnAppStreaming(app_id, type, Application::StreamingState::kSuspended)); + EXPECT_CALL(mock_application_manager_, OnAppStreaming(app_id, type, false)); EXPECT_CALL(*MockMessageHelper::message_helper_mock(), SendOnDataStreaming(type, false, _)); app_impl->SuspendStreaming(type); - EXPECT_CALL( - mock_application_manager_, - OnAppStreaming(app_id, type, Application::StreamingState::kStarted)); + EXPECT_CALL(mock_application_manager_, OnAppStreaming(app_id, type, true)); EXPECT_CALL(*MockMessageHelper::message_helper_mock(), SendOnDataStreaming(type, true, _)); app_impl->WakeUpStreaming(type); @@ -891,9 +888,7 @@ TEST_F(ApplicationImplTest, StopStreaming_StreamingApproved) { protocol_handler::ServiceType::kMobileNav; app_impl->set_video_streaming_approved(true); - EXPECT_CALL( - mock_application_manager_, - OnAppStreaming(app_id, type, Application::StreamingState::kStopped)); + EXPECT_CALL(mock_application_manager_, OnAppStreaming(app_id, type, false)); EXPECT_CALL(mock_application_manager_, ProcessOnDataStreamingNotification(type, app_id, false)); EXPECT_CALL(*MockMessageHelper::message_helper_mock(), @@ -905,9 +900,7 @@ TEST_F(ApplicationImplTest, StopStreaming_StreamingApproved) { // Stop audio streaming app_impl->set_audio_streaming_approved(true); type = protocol_handler::ServiceType::kAudio; - EXPECT_CALL( - mock_application_manager_, - OnAppStreaming(app_id, type, Application::StreamingState::kStopped)); + EXPECT_CALL(mock_application_manager_, OnAppStreaming(app_id, type, false)); EXPECT_CALL(mock_application_manager_, ProcessOnDataStreamingNotification(type, app_id, false)); EXPECT_CALL(*MockMessageHelper::message_helper_mock(), 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 cf8aadb0802..48ba75275bf 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -159,9 +159,7 @@ struct ServiceStatus { : service_type_(type), service_event_(event), reason_(reason) {} }; -class ApplicationManagerImplTest - : public ::testing::Test, - public ::testing::WithParamInterface { +class ApplicationManagerImplTest : public ::testing::Test { public: ApplicationManagerImplTest() : app_id_(0u) @@ -406,9 +404,13 @@ MATCHER_P(HMIFunctionIDIs, result_code, "") { .asInt()); } +class ApplicationManagerImplTestWithServiceStatus + : public ::testing::WithParamInterface, + public ApplicationManagerImplTest {}; + INSTANTIATE_TEST_CASE_P( ProcessServiceStatusUpdate_REQUEST_ACCEPTED, - ApplicationManagerImplTest, + ApplicationManagerImplTestWithServiceStatus, ::testing::Values(ServiceStatus(ServiceType::AUDIO, ServiceEvent::REQUEST_ACCEPTED, UpdateReasonOptional::EMPTY), @@ -421,7 +423,7 @@ INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P( ProcessServiceStatusUpdate_REQUEST_RECEIVED, - ApplicationManagerImplTest, + ApplicationManagerImplTestWithServiceStatus, ::testing::Values(ServiceStatus(ServiceType::AUDIO, ServiceEvent::REQUEST_RECEIVED, UpdateReasonOptional::EMPTY), @@ -434,7 +436,7 @@ INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P( ProcessServiceStatusUpdate_REQUEST_REJECTED, - ApplicationManagerImplTest, + ApplicationManagerImplTestWithServiceStatus, ::testing::Values(ServiceStatus(ServiceType::AUDIO, ServiceEvent::REQUEST_REJECTED, UpdateReasonOptional::EMPTY), @@ -445,7 +447,7 @@ INSTANTIATE_TEST_CASE_P( ServiceEvent::REQUEST_REJECTED, UpdateReasonOptional::EMPTY))); -TEST_P(ApplicationManagerImplTest, +TEST_P(ApplicationManagerImplTestWithServiceStatus, ProcessServiceStatusUpdate_SendMessageToHMI) { smart_objects::SmartObjectSPtr notification_ = std::make_shared( @@ -499,16 +501,16 @@ TEST_F(ApplicationManagerImplTest, ProcessQueryApp_ExpectSuccess) { TEST_F(ApplicationManagerImplTest, SubscribeAppForWayPoints_ExpectSubscriptionApp) { auto app_ptr = std::static_pointer_cast(mock_app_ptr_); - app_manager_impl_->SubscribeAppForWayPoints(app_ptr); + app_manager_impl_->SubscribeAppForWayPoints(app_ptr, true); EXPECT_TRUE(app_manager_impl_->IsAppSubscribedForWayPoints(*app_ptr)); } TEST_F(ApplicationManagerImplTest, - UnsubscribeAppForWayPoints_ExpectUnsubscriptionApp) { + UnsubscribeAppFromWayPoints_ExpectUnsubscriptionApp) { auto app_ptr = std::static_pointer_cast(mock_app_ptr_); - app_manager_impl_->SubscribeAppForWayPoints(app_ptr); + app_manager_impl_->SubscribeAppForWayPoints(app_ptr, true); EXPECT_TRUE(app_manager_impl_->IsAppSubscribedForWayPoints(*app_ptr)); - app_manager_impl_->UnsubscribeAppFromWayPoints(app_ptr); + app_manager_impl_->UnsubscribeAppFromWayPoints(app_ptr, true); EXPECT_FALSE(app_manager_impl_->IsAppSubscribedForWayPoints(*app_ptr)); const std::set result = app_manager_impl_->GetAppsSubscribedForWayPoints(); @@ -520,7 +522,7 @@ TEST_F( IsAnyAppSubscribedForWayPoints_SubcribeAppForWayPoints_ExpectCorrectResult) { EXPECT_FALSE(app_manager_impl_->IsAnyAppSubscribedForWayPoints()); auto app_ptr = std::static_pointer_cast(mock_app_ptr_); - app_manager_impl_->SubscribeAppForWayPoints(app_ptr); + app_manager_impl_->SubscribeAppForWayPoints(app_ptr, true); EXPECT_TRUE(app_manager_impl_->IsAnyAppSubscribedForWayPoints()); } @@ -528,7 +530,7 @@ TEST_F( ApplicationManagerImplTest, GetAppsSubscribedForWayPoints_SubcribeAppForWayPoints_ExpectCorrectResult) { auto app_ptr = std::static_pointer_cast(mock_app_ptr_); - app_manager_impl_->SubscribeAppForWayPoints(app_ptr); + app_manager_impl_->SubscribeAppForWayPoints(app_ptr, true); std::set result = app_manager_impl_->GetAppsSubscribedForWayPoints(); EXPECT_EQ(1u, result.size()); @@ -2294,6 +2296,42 @@ TEST_F( app_manager_impl_->RequestForInterfacesAvailability(); } +class ApplicationManagerImplTestWithFunctionID + : public ::testing::WithParamInterface, + public ApplicationManagerImplTest {}; + +TEST_P(ApplicationManagerImplTestWithFunctionID, + UnsubscribeAppFromSoftButtons_SUCCESS) { + AddMockApplication(); + commands::MessageSharedPtr response_message = + std::make_shared( + smart_objects::SmartType_Map); + + const mobile_apis::FunctionID::eType function_id = GetParam(); + (*response_message)[strings::params][strings::connection_key] = + kConnectionKey; + (*response_message)[strings::msg_params][strings::result_code] = + mobile_apis::Result::SUCCESS; + (*response_message)[strings::params][strings::function_id] = function_id; + + EXPECT_CALL(*mock_app_ptr_, app_id()).WillOnce(Return(kConnectionKey)); + EXPECT_CALL(*mock_app_ptr_, UnsubscribeFromSoftButtons(function_id)); + + const bool unsubscribe_result = + app_manager_impl_->UnsubscribeAppFromSoftButtons(response_message); + + EXPECT_TRUE(unsubscribe_result); +} + +INSTANTIATE_TEST_CASE_P( + UnsubscribeAppFromSoftButtons, + ApplicationManagerImplTestWithFunctionID, + ::testing::Values(mobile_apis::FunctionID::ScrollableMessageID, + mobile_apis::FunctionID::AlertID, + mobile_apis::FunctionID::AlertManeuverID, + mobile_apis::FunctionID::UpdateTurnListID, + mobile_apis::FunctionID::ShowConstantTBTID)); + } // namespace application_manager_test } // namespace components } // namespace test diff --git a/src/components/application_manager/test/hmi_capabilities_test.cc b/src/components/application_manager/test/hmi_capabilities_test.cc index 4e2e9483359..c83dd76978a 100644 --- a/src/components/application_manager/test/hmi_capabilities_test.cc +++ b/src/components/application_manager/test/hmi_capabilities_test.cc @@ -130,6 +130,14 @@ const std::vector light_name_enum_values{ hmi_apis::Common_LightName::eType::EXTERIOR_RIGHT_LIGHTS, hmi_apis::Common_LightName::eType::EXTERIOR_ALL_LIGHTS}; +const std::vector is_ready_requests{ + hmi_apis::FunctionID::RC_IsReady, + hmi_apis::FunctionID::VR_IsReady, + hmi_apis::FunctionID::UI_IsReady, + hmi_apis::FunctionID::TTS_IsReady, + hmi_apis::FunctionID::Navigation_IsReady, + hmi_apis::FunctionID::VehicleInfo_IsReady}; + bool IsLightNameExists(const hmi_apis::Common_LightName::eType& light_name) { auto it = std::find( light_name_enum_values.begin(), light_name_enum_values.end(), light_name); @@ -155,6 +163,13 @@ class HMICapabilitiesTest : public ::testing::Test { .WillByDefault(ReturnRef(kHmiCapabilitiesCacheFile)); hmi_capabilities_ = std::make_shared(mock_app_mngr_); + IsReadyResponsesReceived(); + } + + void IsReadyResponsesReceived() { + for (const auto& request : is_ready_requests) { + hmi_capabilities_->UpdateRequestsRequiredForCapabilities(request); + } } void TearDown() OVERRIDE { @@ -530,16 +545,16 @@ TEST_F( 800, vs_capability_so[strings::preferred_resolution][strings::resolution_width] .asInt()); - EXPECT_EQ(350, + EXPECT_EQ(380, vs_capability_so[strings::preferred_resolution] [strings::resolution_height] .asInt()); EXPECT_TRUE(vs_capability_so.keyExists(strings::max_bitrate)); - EXPECT_EQ(10000, vs_capability_so[strings::max_bitrate].asInt()); + EXPECT_EQ(20000, vs_capability_so[strings::max_bitrate].asInt()); EXPECT_TRUE(vs_capability_so.keyExists(strings::supported_formats)); const size_t supported_formats_len = vs_capability_so[strings::supported_formats].length(); - EXPECT_EQ(1ull, supported_formats_len); + EXPECT_EQ(5u, supported_formats_len); EXPECT_TRUE(vs_capability_so[strings::supported_formats][0].keyExists( strings::protocol)); @@ -554,8 +569,21 @@ TEST_F( EXPECT_TRUE( vs_capability_so.keyExists(strings::haptic_spatial_data_supported)); - EXPECT_FALSE( + EXPECT_TRUE( vs_capability_so[strings::haptic_spatial_data_supported].asBool()); + EXPECT_TRUE(vs_capability_so.keyExists(strings::diagonal_screen_size)); + EXPECT_EQ(8, vs_capability_so[strings::diagonal_screen_size].asInt()); + EXPECT_TRUE(vs_capability_so.keyExists(strings::pixel_per_inch)); + EXPECT_EQ(96, vs_capability_so[strings::pixel_per_inch].asInt()); + EXPECT_TRUE(vs_capability_so.keyExists(strings::scale)); + EXPECT_EQ(1, vs_capability_so[strings::scale].asInt()); + EXPECT_TRUE(vs_capability_so.keyExists(strings::preferred_fps)); + EXPECT_TRUE(vs_capability_so.keyExists( + strings::additional_video_streaming_capabilities)); + const size_t additional_video_streaming_capabilities_len = + vs_capability_so[strings::additional_video_streaming_capabilities] + .length(); + EXPECT_EQ(7u, additional_video_streaming_capabilities_len); EXPECT_TRUE(hmi_capabilities_->video_streaming_supported()); } 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 fdaef2c7166..18afa01a883 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 @@ -53,6 +53,7 @@ namespace components { namespace commands_test { namespace am = ::application_manager; +namespace strings = am::strings; using ::testing::_; using ::testing::Mock; @@ -179,6 +180,30 @@ class CommandsTest : public ::testing::Test { InitHMIToMobileResultConverter(); } + void FillVideoStreamingCapability( + smart_objects::SmartObject& video_streaming_capability) { + video_streaming_capability[strings::preferred_resolution] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + video_streaming_capability[strings::preferred_resolution] + [strings::resolution_width] = 800; + video_streaming_capability[strings::preferred_resolution] + [strings::resolution_height] = 354; + video_streaming_capability[strings::max_bitrate] = 10000; + video_streaming_capability[strings::supported_formats] = + smart_objects::SmartObject(smart_objects::SmartType_Array); + video_streaming_capability[strings::supported_formats][0] = + smart_objects::SmartObject(smart_objects::SmartType_Map); + video_streaming_capability[strings::supported_formats][0] + [strings::protocol] = + hmi_apis::Common_VideoStreamingProtocol::RAW; + video_streaming_capability[strings::supported_formats][0][strings::codec] = + hmi_apis::Common_VideoStreamingCodec::H264; + 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; + } + void InitHMIToMobileResultConverter() { namespace MobileResult = mobile_apis::Result; namespace HMIResult = hmi_apis::Common_Result; diff --git a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h index 60d2f90297b..e3a47f412a6 100644 --- a/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h +++ b/src/components/application_manager/test/include/application_manager/mock_app_service_manager.h @@ -87,6 +87,7 @@ class MockAppServiceManager : public application_manager::AppServiceManager { const bool service_published)); MOCK_METHOD1(UpdateNavigationCapabilities, bool(smart_objects::SmartObject& out_params)); + MOCK_METHOD0(FindWayPointsHandler, application_manager::AppService*()); MOCK_METHOD0(GetRPCPassingHandler, application_manager::RPCPassingHandler&()); }; 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 454b43b99f8..2c9fe688b44 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 @@ -88,8 +88,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)); @@ -206,9 +207,10 @@ class MockApplication : public ::application_manager::Application { 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)); + MOCK_METHOD2( + SubscribeToSoftButtons, + void(int32_t cmd_id, + const application_manager::WindowSoftButtons& window_softbuttons)); MOCK_METHOD1(IsSubscribedToSoftButton, bool(const uint32_t softbutton_id)); MOCK_METHOD1(UnsubscribeFromSoftButtons, void(int32_t cmd_id)); MOCK_CONST_METHOD0(IsAudioApplication, bool()); 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 2f9f40ad2ac..e40197cc13f 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 @@ -212,6 +212,8 @@ class MockHMICapabilities : public ::application_manager::HMICapabilities { MOCK_CONST_METHOD0(ccpu_version, const std::string&()); MOCK_METHOD1(set_ccpu_version, void(const std::string& ccpu_version)); + MOCK_CONST_METHOD0(hardware_version, const std::string&()); + MOCK_METHOD1(set_hardware_version, void(const std::string& hardware_version)); MOCK_METHOD1(OnSoftwareVersionReceived, void(const std::string& ccpu_version)); MOCK_METHOD0(UpdateCachedCapabilities, void()); 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 d7919a374b5..89b2d125e5f 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 @@ -182,6 +182,12 @@ class MockMessageHelper { smart_objects::SmartObjectSPtr( const ResetGlobalPropertiesResult& reset_result, ApplicationSharedPtr application)); + + MOCK_METHOD2(CreateRCResetGlobalPropertiesRequest, + smart_objects::SmartObjectSPtr( + const ResetGlobalPropertiesResult& reset_result, + ApplicationSharedPtr application)); + MOCK_METHOD2(CreateGlobalPropertiesRequestsToHMI, smart_objects::SmartObjectList(ApplicationConstSharedPtr app, ApplicationManager& app_mngr)); 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 e38b428877e..0596b4e500e 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 @@ -157,6 +157,7 @@ class ResumptionDataTest : public ::testing::Test { am::SubMenuMap test_submenu_map; am::ChoiceSetMap test_choiceset_map; am::AppFilesMap app_files_map_; + smart_objects::SmartObject user_location_; am::ButtonSubscriptions btn_subscr; 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 c380805bc21..f6ee2b654aa 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 @@ -46,6 +46,7 @@ #include "application_manager/mock_rpc_service.h" #include "application_manager/policies/policy_handler.h" #include "application_manager/resumption/resume_ctrl.h" +#include "application_manager/rpc_plugins/rc_rpc_plugin/include/rc_rpc_plugin/rc_module_constants.h" #include "application_manager/state_controller.h" #include "policy/mock_policy_settings.h" #include "smart_objects/enum_schema_item.h" @@ -167,6 +168,12 @@ TEST(MessageHelperTestCreate, EXPECT_CALL(*mock_help_prompt_manager, GetSendingType()) .WillRepeatedly(Return(HelpPromptManager::SendingType::kSendBoth)); + smart_objects::SmartObject user_loc = + smart_objects::SmartObject(smart_objects::SmartType_Map); + + EXPECT_CALL(*appSharedMock, get_user_location()) + .WillRepeatedly(ReturnRef(user_loc)); + application_manager_test::MockApplicationManager mock_application_manager; smart_objects::SmartObjectList ptr = MessageHelper::CreateGlobalPropertiesRequestsToHMI( @@ -189,6 +196,10 @@ TEST(MessageHelperTestCreate, (*objPtr)[5][strings::help_prompt] = "666"; (*objPtr)[6][strings::timeout_prompt] = "777"; + smart_objects::SmartObject user_loc = + smart_objects::SmartObject(smart_objects::SmartType_Map); + user_loc[rc_rpc_plugin::strings::kGrid] = "[]"; + EXPECT_CALL(*appSharedMock, vr_help_title()) .Times(AtLeast(3)) .WillRepeatedly(Return(&(*objPtr)[0])); @@ -211,6 +222,8 @@ TEST(MessageHelperTestCreate, .Times(AtLeast(2)) .WillRepeatedly(Return(&(*objPtr)[4])); EXPECT_CALL(*appSharedMock, app_id()).WillRepeatedly(Return(0)); + EXPECT_CALL(*appSharedMock, get_user_location()) + .WillRepeatedly(ReturnRef(user_loc)); std::shared_ptr mock_help_prompt_manager = std::make_shared(); @@ -888,16 +901,46 @@ TEST_F(MessageHelperTest, } } -TEST_F(MessageHelperTest, SubscribeApplicationToSoftButton_CallFromApp) { - // Create application mock +TEST_F( + MessageHelperTest, + SubscribeApplicationToSoftButton_SoftbuttonsAreAbsent_DoesntCallFromApp) { + MockApplicationSharedPtr appSharedPtr = std::make_shared(); + smart_objects::SmartObject message_params; + size_t function_id = 1; + WindowSoftButtons window_buttons{ + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, {}}; + + EXPECT_CALL(*appSharedPtr, + SubscribeToSoftButtons(function_id, window_buttons)) + .Times(0); + MessageHelper::SubscribeApplicationToSoftButton( + message_params, appSharedPtr, function_id); +} + +TEST_F(MessageHelperTest, + SubscribeApplicationToSoftButton_SoftbuttonsExist_CallFromApp) { MockApplicationSharedPtr appSharedPtr = std::make_shared(); - // Prepare data for method smart_objects::SmartObject message_params; + message_params[strings::soft_buttons] = + new smart_objects::SmartObject(smart_objects::SmartType_Array); + const uint32_t softbutton1 = 1u; + const uint32_t softbutton2 = 2u; + const uint32_t softbutton3 = 3u; + message_params[strings::soft_buttons][0][strings::soft_button_id] = + softbutton1; + message_params[strings::soft_buttons][1][strings::soft_button_id] = + softbutton2; + message_params[strings::soft_buttons][2][strings::soft_button_id] = + softbutton3; + size_t function_id = 1; - // + WindowSoftButtons window_buttons{ + mobile_apis::PredefinedWindows::DEFAULT_WINDOW, + {softbutton1, softbutton2, softbutton3}}; + EXPECT_CALL(*appSharedPtr, - SubscribeToSoftButtons(function_id, SoftButtonID())) - .Times(1); + SubscribeToSoftButtons(function_id, window_buttons)); + MessageHelper::SubscribeApplicationToSoftButton( message_params, appSharedPtr, function_id); } diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index 91f953eaf5e..554b99ff727 100644 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -582,6 +582,14 @@ MessageHelper::CreateTTSResetGlobalPropertiesRequest( ->CreateTTSResetGlobalPropertiesRequest(reset_result, application); } +smart_objects::SmartObjectSPtr +MessageHelper::CreateRCResetGlobalPropertiesRequest( + const ResetGlobalPropertiesResult& reset_result, + ApplicationSharedPtr application) { + return MockMessageHelper::message_helper_mock() + ->CreateRCResetGlobalPropertiesRequest(reset_result, application); +} + smart_objects::SmartObjectList MessageHelper::CreateGlobalPropertiesRequestsToHMI( ApplicationConstSharedPtr app, ApplicationManager& app_mngr) { diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc index 39ad034d6f6..1d764526b9a 100644 --- a/src/components/application_manager/test/policy_handler_test.cc +++ b/src/components/application_manager/test/policy_handler_test.cc @@ -72,6 +72,7 @@ #include "policy/mock_policy_manager.h" #include "policy/usage_statistics/mock_statistics_manager.h" #include "protocol_handler/mock_session_observer.h" +#include "utils/test_async_waiter.h" #include "smart_objects/enum_schema_item.h" @@ -291,40 +292,6 @@ class PolicyHandlerTest : public ::testing::Test { } }; -namespace { -/** - * @brief The WaitAsync class - * can wait for a certain amount of function calls from different - * threads, or a timeout expires. - */ -class WaitAsync { - public: - WaitAsync(const uint32_t count, const uint32_t timeout) - : count_(count), timeout_(timeout) {} - - void Notify() { - count_--; - cond_var_.NotifyOne(); - } - - bool Wait(sync_primitives::AutoLock& auto_lock) { - while (count_ > 0) { - sync_primitives::ConditionalVariable::WaitStatus wait_status = - cond_var_.WaitFor(auto_lock, timeout_); - if (wait_status == sync_primitives::ConditionalVariable::kTimeout) { - return false; - } - } - return true; - } - - private: - int count_; - const uint32_t timeout_; - sync_primitives::ConditionalVariable cond_var_; -}; -} // namespace - TEST_F(PolicyHandlerTest, LoadPolicyLibrary_Method_ExpectLibraryLoaded) { // Check before policy enabled from ini file EXPECT_CALL(policy_settings_, enable_policy()).WillRepeatedly(Return(false)); @@ -926,8 +893,8 @@ void PolicyHandlerTest::TestActivateApp(const uint32_t connection_key, _, _)); #endif // EXTERNAL_PROPRIETARY_MODE - - EXPECT_CALL(*application1, policy_app_id()).WillOnce(Return(kPolicyAppId_)); + EXPECT_CALL(*application1, policy_app_id()) + .WillRepeatedly(Return(kPolicyAppId_)); EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(kMacAddr_, kPolicyAppId_)) .WillOnce(Return(permissions)); @@ -1323,19 +1290,6 @@ TEST_F(PolicyHandlerTest, OnSystemInfoChanged) { policy_handler_.OnSystemInfoChanged(language); } -TEST_F(PolicyHandlerTest, OnGetSystemInfo) { - // Arrange - ChangePolicyManagerToMock(); - // Check expectations - const std::string ccpu_version("4.1.3.B_EB355B"); - const std::string wers_country_code("WAEGB"); - const std::string language("ru-ru"); - EXPECT_CALL(*mock_policy_manager_, - SetSystemInfo(ccpu_version, wers_country_code, language)); - // Act - policy_handler_.OnGetSystemInfo(ccpu_version, wers_country_code, language); -} - TEST_F(PolicyHandlerTest, IsApplicationRevoked) { // Arrange EnablePolicy(); @@ -1915,7 +1869,7 @@ TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_ConsentAllowed) { EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId_)); EXPECT_CALL(*mock_policy_manager_, IsPredataPolicy(kPolicyAppId_)) - .WillOnce(Return(true)); + .WillRepeatedly(Return(true)); EXPECT_CALL( *mock_policy_manager_, @@ -1944,7 +1898,7 @@ TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_ConsentNotAllowed) { EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId_)); EXPECT_CALL(*mock_policy_manager_, IsPredataPolicy(kPolicyAppId_)) - .WillOnce(Return(true)); + .WillRepeatedly(Return(true)); EXPECT_CALL(*mock_policy_manager_, ReactOnUserDevConsentForApp(handle, kPolicyAppId_, is_allowed)) @@ -1976,7 +1930,7 @@ TEST_F(PolicyHandlerTest, OnDeviceConsentChanged_PredatePolicyNotAllowed) { // App does not have predate policy EXPECT_CALL(*mock_policy_manager_, IsPredataPolicy(kPolicyAppId_)) - .WillOnce(Return(false)); + .WillRepeatedly(Return(false)); EXPECT_CALL( *mock_policy_manager_, @@ -2258,24 +2212,20 @@ TEST_F(PolicyHandlerTest, EXPECT_CALL(*mock_app_, policy_app_id()).WillOnce(Return(kPolicyAppId_)); EXPECT_CALL(*mock_app_, device()).WillOnce(Return(device)); - sync_primitives::Lock wait_hmi_lock_first; - sync_primitives::AutoLock auto_lock_first(wait_hmi_lock_first); - WaitAsync waiter_first(kCallsCount_, kTimeout_); + auto waiter_first = TestAsyncWaiter::createInstance(); #ifdef EXTERNAL_PROPRIETARY_MODE EXPECT_CALL(*mock_policy_manager_, SetUserConsentForApp(_, _)) - .WillOnce(NotifyAsync(&waiter_first)); + .WillOnce(NotifyTestAsyncWaiter(waiter_first)); #else EXPECT_CALL(*mock_policy_manager_, SetUserConsentForApp(_)) - .WillOnce(NotifyAsync(&waiter_first)); + .WillOnce(NotifyTestAsyncWaiter(waiter_first)); #endif ExternalConsentStatusItem item(1u, 1u, kStatusOn); ExternalConsentStatus external_consent_status; external_consent_status.insert(item); #ifdef EXTERNAL_PROPRIETARY_MODE - sync_primitives::Lock wait_hmi_lock_second; - sync_primitives::AutoLock auto_lock_second(wait_hmi_lock_second); - WaitAsync waiter_second(kCallsCount_, kTimeout_); + auto waiter_second = TestAsyncWaiter::createInstance(); EXPECT_CALL(*mock_policy_manager_, SetExternalConsentStatus(external_consent_status)) @@ -2286,9 +2236,9 @@ TEST_F(PolicyHandlerTest, policy_handler_.OnAppPermissionConsent(kConnectionKey_, permissions); #endif - EXPECT_TRUE(waiter_first.Wait(auto_lock_first)); + EXPECT_TRUE(waiter_first->WaitFor(kCallsCount_, kTimeout_)); #ifdef EXTERNAL_PROPRIETARY_MODE - EXPECT_TRUE(waiter_second.Wait(auto_lock_second)); + EXPECT_TRUE(waiter_second->WaitFor(kCallsCount_, kTimeout_)); #endif } @@ -2309,9 +2259,7 @@ TEST_F(PolicyHandlerTest, permissions.group_permissions.push_back(group_permission_allowed); - sync_primitives::Lock wait_hmi_lock; - sync_primitives::AutoLock auto_lock(wait_hmi_lock); - WaitAsync waiter(kCallsCount_, kTimeout_); + auto waiter = TestAsyncWaiter::createInstance(); EXPECT_CALL(app_manager_, application(_)).Times(0); @@ -2328,7 +2276,7 @@ TEST_F(PolicyHandlerTest, policy_handler_.OnAppPermissionConsent(invalid_connection_key, permissions); #endif - EXPECT_FALSE(waiter.Wait(auto_lock)); + EXPECT_FALSE(waiter->WaitFor(kCallsCount_, kTimeout_)); } TEST_F(PolicyHandlerTest, @@ -2348,9 +2296,7 @@ TEST_F(PolicyHandlerTest, permissions.group_permissions.push_back(group_permission_allowed); - sync_primitives::Lock wait_hmi_lock; - sync_primitives::AutoLock auto_lock(wait_hmi_lock); - WaitAsync waiter(kCallsCount_, kTimeout_); + auto waiter = TestAsyncWaiter::createInstance(); EXPECT_CALL(app_manager_, application(_)).Times(0); @@ -2369,7 +2315,7 @@ TEST_F(PolicyHandlerTest, policy_handler_.OnAppPermissionConsent(invalid_connection_key, permissions); #endif - EXPECT_FALSE(waiter.Wait(auto_lock)); + EXPECT_FALSE(waiter->WaitFor(kCallsCount_, kTimeout_)); } ACTION_P(SetDeviceParamsMacAdress, mac_adress) { @@ -2421,13 +2367,11 @@ TEST_F(PolicyHandlerTest, ExternalConsentStatus external_consent_status; external_consent_status.insert(item); #ifdef EXTERNAL_PROPRIETARY_MODE - sync_primitives::Lock wait_hmi_lock; - sync_primitives::AutoLock auto_lock(wait_hmi_lock); - WaitAsync waiter(kCallsCount_, kTimeout_); + auto waiter = TestAsyncWaiter::createInstance(); EXPECT_CALL(*mock_policy_manager_, SetExternalConsentStatus(external_consent_status)) - .WillOnce(DoAll(NotifyAsync(&waiter), Return(true))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); policy_handler_.OnAppPermissionConsent( invalid_connection_key, permissions, external_consent_status); #else @@ -2436,7 +2380,7 @@ TEST_F(PolicyHandlerTest, Mock::VerifyAndClearExpectations(mock_app_.get()); #ifdef EXTERNAL_PROPRIETARY_MODE - EXPECT_TRUE(waiter.Wait(auto_lock)); + EXPECT_TRUE(waiter->WaitFor(kCallsCount_, kTimeout_)); #endif } @@ -2485,9 +2429,7 @@ TEST_F(PolicyHandlerTest, ExternalConsentStatus external_consent_status; external_consent_status.insert(item); #ifdef EXTERNAL_PROPRIETARY_MODE - sync_primitives::Lock wait_hmi_lock; - sync_primitives::AutoLock auto_lock(wait_hmi_lock); - WaitAsync waiter(kCallsCount_, kTimeout_); + auto waiter = TestAsyncWaiter::createInstance(); ON_CALL(*mock_policy_manager_, IsNeedToUpdateExternalConsentStatus(_)) .WillByDefault(Return(false)); @@ -2502,7 +2444,7 @@ TEST_F(PolicyHandlerTest, Mock::VerifyAndClearExpectations(mock_app_.get()); #ifdef EXTERNAL_PROPRIETARY_MODE - EXPECT_FALSE(waiter.Wait(auto_lock)); + EXPECT_FALSE(waiter->WaitFor(kCallsCount_, kTimeout_)); #endif } @@ -2553,37 +2495,33 @@ TEST_F(PolicyHandlerTest, AddStatisticsInfo_UnknownStatistics_UNSUCCESS) { TEST_F(PolicyHandlerTest, AddStatisticsInfo_SUCCESS) { EnablePolicyAndPolicyManagerMock(); - sync_primitives::Lock wait_hmi_lock; - sync_primitives::AutoLock auto_lock(wait_hmi_lock); - WaitAsync waiter(kCallsCount_, kTimeout_); + auto waiter = TestAsyncWaiter::createInstance(); EXPECT_CALL(*mock_policy_manager_, Increment(_)) - .WillOnce(NotifyAsync(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); policy_handler_.AddStatisticsInfo( hmi_apis::Common_StatisticsType::iAPP_BUFFER_FULL); - EXPECT_TRUE(waiter.Wait(auto_lock)); + EXPECT_TRUE(waiter->WaitFor(kCallsCount_, kTimeout_)); } TEST_F(PolicyHandlerTest, OnSystemError_SUCCESS) { EnablePolicyAndPolicyManagerMock(); - sync_primitives::Lock wait_hmi_lock; - sync_primitives::AutoLock auto_lock(wait_hmi_lock); - WaitAsync waiter(kCallsCount_, kTimeout_); + auto waiter_first = TestAsyncWaiter::createInstance(); EXPECT_CALL(*mock_policy_manager_, Increment(_)) - .WillOnce(NotifyAsync(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter_first)); policy_handler_.OnSystemError(hmi_apis::Common_SystemError::SYNC_REBOOTED); - EXPECT_TRUE(waiter.Wait(auto_lock)); + EXPECT_TRUE(waiter_first->WaitFor(kCallsCount_, kTimeout_)); - WaitAsync waiter1(kCallsCount_, kTimeout_); - EXPECT_CALL(*mock_policy_manager_, Increment(_)) - .WillOnce(NotifyAsync(&waiter1)); + auto waiter_second = TestAsyncWaiter::createInstance(); + EXPECT_CALL(*mock_policy_manager_, Increment(_)) + .WillOnce(NotifyTestAsyncWaiter(waiter_second)); policy_handler_.OnSystemError( hmi_apis::Common_SystemError::SYNC_OUT_OF_MEMMORY); - EXPECT_TRUE(waiter1.Wait(auto_lock)); + EXPECT_TRUE(waiter_second->WaitFor(kCallsCount_, kTimeout_)); } TEST_F(PolicyHandlerTest, RemoteAppsUrl_EndpointsEmpty_UNSUCCESS) { 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 71e12b2825b..992bf8e303e 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 @@ -162,35 +162,35 @@ class RequestControllerTestClass : public ::testing::Test { TEST_F(RequestControllerTestClass, AddMobileRequest_DuplicateCorrelationId_INVALID_ID) { RequestPtr request_valid = GetMockRequest(); - TestAsyncWaiter waiter_valid; + auto waiter_valid = TestAsyncWaiter::createInstance(); ON_CALL(*request_valid, default_timeout()).WillByDefault(Return(0)); EXPECT_CALL(*request_valid, Init()).WillOnce(Return(true)); EXPECT_CALL(*request_valid, Run()) .Times(1) - .WillRepeatedly(NotifyTestAsyncWaiter(&waiter_valid)); + .WillRepeatedly(NotifyTestAsyncWaiter(waiter_valid)); EXPECT_EQ(RequestController::SUCCESS, AddRequest(default_settings_, request_valid, RequestInfo::RequestType::MobileRequest, mobile_apis::HMILevel::HMI_NONE)); - EXPECT_TRUE(waiter_valid.WaitFor(1, 1000)); + EXPECT_TRUE(waiter_valid->WaitFor(1, 1000)); // The command should not be run if another command with the same // correlation_id is waiting for a response RequestPtr request_dup_corr_id = GetMockRequest(); - TestAsyncWaiter waiter_dup; + auto waiter_dup = TestAsyncWaiter::createInstance(); ON_CALL(*request_dup_corr_id, default_timeout()).WillByDefault(Return(0)); EXPECT_CALL(*request_dup_corr_id, Init()).WillOnce(Return(true)); ON_CALL(*request_dup_corr_id, Run()) - .WillByDefault(NotifyTestAsyncWaiter(&waiter_dup)); + .WillByDefault(NotifyTestAsyncWaiter(waiter_dup)); EXPECT_EQ(RequestController::SUCCESS, AddRequest(default_settings_, request_dup_corr_id, RequestInfo::RequestType::MobileRequest, mobile_apis::HMILevel::HMI_NONE)); - EXPECT_FALSE(waiter_dup.WaitFor(1, 1000)); + EXPECT_FALSE(waiter_dup->WaitFor(1, 1000)); } TEST_F(RequestControllerTestClass, @@ -282,17 +282,17 @@ TEST_F(RequestControllerTestClass, OnTimer_SUCCESS) { RequestPtr mock_request = GetMockRequest( kDefaultCorrelationID, kDefaultConnectionKey, request_timeout); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); EXPECT_EQ(RequestController::SUCCESS, AddRequest(default_settings_, mock_request, RequestInfo::RequestType::MobileRequest)); EXPECT_CALL(*mock_request, onTimeOut()) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); // Waiting for call of `onTimeOut` for `kTimeScale` seconds - EXPECT_TRUE(waiter.WaitFor(1, kTimeScale)); + EXPECT_TRUE(waiter->WaitFor(1, kTimeScale)); } } // namespace request_controller_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 8d228240d2d..a265b2b3414 100644 --- a/src/components/application_manager/test/resumption/resume_ctrl_test.cc +++ b/src/components/application_manager/test/resumption/resume_ctrl_test.cc @@ -685,9 +685,9 @@ TEST_F(ResumeCtrlTest, extensions.insert(extensions.begin(), mock_app_extension_); EXPECT_CALL(*mock_app_, Extensions()).WillOnce(ReturnRef(extensions)); - EXPECT_CALL( - mock_app_mngr_, - SubscribeAppForWayPoints(A())); + EXPECT_CALL(mock_app_mngr_, + SubscribeAppForWayPoints( + A(), true)); const mobile_apis::HMILevel::eType hmi_test_level = mobile_apis::HMILevel::HMI_FULL; ON_CALL(mock_app_mngr_, GetDefaultHmiLevel(const_app_)) 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 d5228934db3..a416cbbad52 100644 --- a/src/components/application_manager/test/resumption/resumption_data_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_test.cc @@ -437,6 +437,8 @@ void ResumptionDataTest::PrepareData() { ON_CALL(*app_mock, getAppFiles()).WillByDefault(ReturnRef(app_files_map_)); ON_CALL(*app_mock, window_optional_params_map()) .WillByDefault(Return(window_params_map)); + ON_CALL(*app_mock, get_user_location()) + .WillByDefault(ReturnRef(user_location_)); } void ResumptionDataTest::SetDefaultCurrentHmiState() { 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 61490ae4aff..f31d8f8e28a 100644 --- a/src/components/application_manager/test/resumption_sql_queries_test.cc +++ b/src/components/application_manager/test/resumption_sql_queries_test.cc @@ -81,6 +81,7 @@ const string kDeleteData = "DELETE FROM `applicationSubMenuArray`; " "DELETE FROM `applicationSubscriptionsArray`; " "DELETE FROM `_internal_data`; " + "DELETE FROM `applicationUserLocation`;" "COMMIT; " "VACUUM;"; @@ -329,6 +330,7 @@ class ResumptionSqlQueriesTest : public ::testing::Test { db_schema.push_back("applicationSubMenuArray"); db_schema.push_back("applicationSubscriptionsArray"); db_schema.push_back("_internal_data"); + db_schema.push_back("applicationUserLocation"); std::sort(db_schema.begin(), db_schema.end()); } }; diff --git a/src/components/application_manager/test/rpc_passing_handler_test.cc b/src/components/application_manager/test/rpc_passing_handler_test.cc index 6eac6ca0b1c..4e7f4016466 100644 --- a/src/components/application_manager/test/rpc_passing_handler_test.cc +++ b/src/components/application_manager/test/rpc_passing_handler_test.cc @@ -390,7 +390,7 @@ TEST_F(RPCPassingHandlerTest, TEST_F(RPCPassingHandlerTest, RPCPassingTest_REQUEST_Timeout) { uint32_t timeout_in_ms = 4; - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); app_services_.push_back(CreateAppService( kConnectionKey_NAV_ASP, "Navigation service", "NAVIGATION")); diff --git a/src/components/application_manager/test/sdl_preloaded_pt.json b/src/components/application_manager/test/sdl_preloaded_pt.json deleted file mode 100644 index 536a0939f9b..00000000000 --- a/src/components/application_manager/test/sdl_preloaded_pt.json +++ /dev/null @@ -1,1979 +0,0 @@ - { - "policy_table": { - "module_config": { - "preloaded_pt": true, - "preloaded_date": "2015-02-12", - "exchange_after_x_ignition_cycles": 100, - "exchange_after_x_kilometers": 1800, - "exchange_after_x_days": 30, - "timeout_after_x_seconds": 70, - "seconds_between_retries": [1, - 5, - 25, - 125, - 625], - "endpoints": { - "0x07": { - "default": ["http://x.x.x.x:3000/api/1/policies"] - } - }, - "notifications_per_minute_by_priority": { - "EMERGENCY": 60, - "NAVIGATION": 15, - "PROJECTION": 15, - "VOICECOM": 20, - "COMMUNICATION": 6, - "NORMAL": 4, - "NONE": 0 - }, - "subtle_notifications_per_minute_by_priority": { - "EMERGENCY": 60, - "NAVIGATION": 20, - "PROJECTION": 20, - "VOICECOM": 30, - "COMMUNICATION": 15, - "NORMAL": 10, - "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"] - }, - "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": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "OnDriverDistraction": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "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"] - }, - "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", - "LIMITED"] - }, - "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"] - } - } - }, - "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", - "stabilityControlsStatus"] - }, - "OnVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["bodyInformation", - "deviceStatus", - "engineOilLife", - "engineTorque", - "externalTemperature", - "turnSignal", - "fuelLevel", - "fuelLevel_State", - "headLampStatus", - "instantFuelConsumption", - "fuelRange", - "cloudAppVehicleID", - "odometer", - "tirePressure", - "vin", - "wiperStatus", - "stabilityControlsStatus"] - }, - "SubscribeVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["bodyInformation", - "deviceStatus", - "engineOilLife", - "engineTorque", - "externalTemperature", - "turnSignal", - "fuelLevel", - "fuelLevel_State", - "headLampStatus", - "instantFuelConsumption", - "fuelRange", - "cloudAppVehicleID", - "odometer", - "tirePressure", - "wiperStatus", - "stabilityControlsStatus"] - }, - "UnsubscribeVehicleData": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"], - "parameters": ["bodyInformation", - "deviceStatus", - "engineOilLife", - "engineTorque", - "externalTemperature", - "turnSignal", - "fuelLevel", - "fuelLevel_State", - "headLampStatus", - "instantFuelConsumption", - "fuelRange", - "cloudAppVehicleID", - "odometer", - "tirePressure", - "wiperStatus", - "stabilityControlsStatus"] - } - } - }, - "PropriataryData-1": { - "rpcs": { - "DiagnosticMessage": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "GetDTCs": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - }, - "ReadDID": { - "hmi_levels": ["BACKGROUND", - "FULL", - "LIMITED"] - } - } - }, - "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"] - } - } - }, - "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"] - }, - "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"] - } - } - } - }, - "consumer_friendly_messages": { - "version": "001.001.019", - "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)?" - }, - "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" - }, - "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" - }, - "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. Updates 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?\n\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.\n\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-en": { - "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. 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. /r Presione 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 Veuillez appuyer sur Oui pour autoriser ou sur Non pour refuser." - } - } - }, - "DataConsentHelp": { - "languages": { - "en-us": { - "textBody": "Updates 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. See your Owner Guide for more information." - }, - "es-en": { - "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": "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." - }, - "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.?" - }, - "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" - }, - "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" - }, - "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" - }, - "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." - }, - "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 authorization information 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." - }, - "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." - }, - "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..." - }, - "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" - }, - "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" - }, - "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": [ - "QUERY_APPS", - "LAUNCH_APP", - "PROPRIETARY" - ] - }, - "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"], - "RequestType": ["HTTP"] - } - } - } - } diff --git a/src/components/config_profile/include/config_profile/profile.h b/src/components/config_profile/include/config_profile/profile.h index bbd0a5d2434..dffa2d15714 100644 --- a/src/components/config_profile/include/config_profile/profile.h +++ b/src/components/config_profile/include/config_profile/profile.h @@ -552,6 +552,11 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, */ size_t update_before_hours() const; + /** + * @brief Return security level that will be configured in the OpenSSL + */ + uint32_t security_level() const; + #endif // ENABLE_SECURITY /** @@ -1073,6 +1078,7 @@ class Profile : public protocol_handler::ProtocolHandlerSettings, std::string security_manager_protocol_name_; std::vector force_protected_service_; std::vector force_unprotected_service_; + uint32_t security_level_; #endif /* diff --git a/src/components/config_profile/src/profile.cc b/src/components/config_profile/src/profile.cc index d9204acf90f..27829d478fd 100644 --- a/src/components/config_profile/src/profile.cc +++ b/src/components/config_profile/src/profile.cc @@ -140,6 +140,7 @@ const char* kSecurityKeyPathKey = "KeyPath"; const char* kSecurityCipherListKey = "CipherList"; const char* kSecurityVerifyPeerKey = "VerifyPeer"; const char* kBeforeUpdateHours = "UpdateBeforeHours"; +const char* kSecurityLevel = "SecurityLevel"; #endif const char* kAudioDataStoppedTimeoutKey = "AudioDataStoppedTimeout"; @@ -337,6 +338,7 @@ const char* kDefaultSecurityProtocol = "TLSv1.2"; const char* kDefaultSSLMode = "CLIENT"; const bool kDefaultVerifyPeer = false; const uint32_t kDefaultBeforeUpdateHours = 24; +const uint32_t kDefaultSecurityLevel = 1; #endif // ENABLE_SECURITY const uint32_t kDefaultHubProtocolIndex = 0; @@ -1117,6 +1119,10 @@ const std::vector& Profile::force_protected_service() const { const std::vector& Profile::force_unprotected_service() const { return force_unprotected_service_; } + +uint32_t Profile::security_level() const { + return security_level_; +} #endif // ENABLE_SECURITY bool Profile::logs_enabled() const { @@ -1308,6 +1314,11 @@ void Profile::UpdateValues() { kSecuritySection, kBeforeUpdateHours); + ReadUIntValue(&security_level_, + kDefaultSecurityLevel, + kSecuritySection, + kSecurityLevel); + #endif // ENABLE_SECURITY // Logs enabled diff --git a/src/components/connection_handler/include/connection_handler/connection.h b/src/components/connection_handler/include/connection_handler/connection.h index 8b286e1309d..4ef2d724c3c 100644 --- a/src/components/connection_handler/include/connection_handler/connection.h +++ b/src/components/connection_handler/include/connection_handler/connection.h @@ -279,6 +279,14 @@ class Connection { */ void KeepAlive(uint8_t session_id); + /** + * @brief Check is heartbeat monitoring started for specified session + * @param session_id session id + * @return returns true if heartbeat monitoring started for specified session + * otherwise returns false + */ + bool IsSessionHeartbeatTracked(const uint8_t session_id) const; + /** * @brief Start heartbeat for specified session * @param session_id session id 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 3bfa5b34b8d..25a89ea4b35 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 @@ -465,6 +465,14 @@ class ConnectionHandlerImpl */ void SendEndService(uint32_t key, uint8_t service_type) OVERRIDE; + /** + * @brief Check is heartbeat monitoring started for specified connection key + * @param connection_key pair of connection and session id + * @return returns true if heartbeat monitoring started for specified + * connection key otherwise returns false + */ + bool IsSessionHeartbeatTracked(const uint32_t connection_key) const OVERRIDE; + /** * \brief Start heartbeat for specified session * @@ -640,6 +648,8 @@ class ConnectionHandlerImpl void CreateWebEngineDevice() OVERRIDE; + bool GetProtocolVehicleData(ProtocolVehicleData& data) OVERRIDE; + private: /** * \brief Disconnect application. 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 9e04929f796..7713d2490f7 100644 --- a/src/components/connection_handler/include/connection_handler/heartbeat_monitor.h +++ b/src/components/connection_handler/include/connection_handler/heartbeat_monitor.h @@ -68,6 +68,14 @@ class HeartBeatMonitor : public threads::ThreadDelegate { */ void KeepAlive(uint8_t session_id); + /** + * @brief Check is heartbeat monitoring started for specified session + * @param session_id session id + * @return returns true if heartbeat monitoring started for specified session + * otherwise returns false + */ + bool IsSessionHeartbeatTracked(const uint8_t session_id) const; + /** * \brief Thread exit procedure. */ @@ -111,7 +119,7 @@ class HeartBeatMonitor : public threads::ThreadDelegate { typedef std::map SessionMap; SessionMap sessions_; - sync_primitives::RecursiveLock sessions_list_lock_; // recurcive + mutable sync_primitives::RecursiveLock sessions_list_lock_; // recursive sync_primitives::Lock main_thread_lock_; mutable sync_primitives::Lock heartbeat_timeout_seconds_lock_; sync_primitives::ConditionalVariable heartbeat_monitor_; diff --git a/src/components/connection_handler/src/connection.cc b/src/components/connection_handler/src/connection.cc index 5bd72773c26..0ed5182a9b0 100644 --- a/src/components/connection_handler/src/connection.cc +++ b/src/components/connection_handler/src/connection.cc @@ -527,6 +527,10 @@ bool Connection::ProtocolVersion(uint8_t session_id, return true; } +bool Connection::IsSessionHeartbeatTracked(const uint8_t session_id) const { + return heartbeat_monitor_->IsSessionHeartbeatTracked(session_id); +} + bool Connection::ProtocolVersion( uint8_t session_id, utils::SemanticVersion& full_protocol_version) { SDL_LOG_AUTO_TRACE(); diff --git a/src/components/connection_handler/src/connection_handler_impl.cc b/src/components/connection_handler/src/connection_handler_impl.cc index 549450dbe0e..cb7fc31575f 100644 --- a/src/components/connection_handler/src/connection_handler_impl.cc +++ b/src/components/connection_handler/src/connection_handler_impl.cc @@ -547,11 +547,16 @@ void ConnectionHandlerImpl::OnSessionStartedCallback( session_key, service_type, params); - } else { + } +#ifdef BUILD_TESTS + else { + // FIXME (VSemenyuk): This code is only used in unit tests, so should be + // removed. ConnectionHandler unit tests should be fixed. if (protocol_handler_) { protocol_handler_->NotifySessionStarted(context, rejected_params); } } +#endif } void ConnectionHandlerImpl::NotifyServiceStartedResult( @@ -589,17 +594,20 @@ void ConnectionHandlerImpl::NotifyServiceStartedResult( if (!result) { SDL_LOG_WARN("Service starting forbidden by connection_handler_observer"); + context.is_start_session_failed_ = true; + } + + if (protocol_handler_) { + protocol_handler_->NotifySessionStarted(context, rejected_params, reason); + } + + if (context.is_start_session_failed_) { if (protocol_handler::kRpc == context.service_type_) { connection->RemoveSession(context.new_session_id_); } else { connection->RemoveService(context.initial_session_id_, context.service_type_); } - context.new_session_id_ = 0; - } - - if (protocol_handler_ != NULL) { - protocol_handler_->NotifySessionStarted(context, rejected_params, reason); } } @@ -919,6 +927,15 @@ void ConnectionHandlerImpl::CreateWebEngineDevice() { transport_manager_.CreateWebEngineDevice(); } +bool ConnectionHandlerImpl::GetProtocolVehicleData(ProtocolVehicleData& data) { + sync_primitives::AutoReadLock read_lock(connection_handler_observer_lock_); + if (connection_handler_observer_) { + return connection_handler_observer_->GetProtocolVehicleData(data); + } + + return false; +} + const std::string ConnectionHandlerImpl::TransportTypeProfileStringFromConnHandle( transport_manager::ConnectionUID connection_handle) const { @@ -1457,6 +1474,10 @@ void ConnectionHandlerImpl::ConnectToAllDevices() { SDL_LOG_DEBUG("No need to connect to web engine device"); continue; } + if ("CLOUD_WEBSOCKET" == i->second.connection_type()) { + SDL_LOG_DEBUG("No need to connect to cloud device"); + continue; + } ConnectToDevice(i->first); } } @@ -1667,6 +1688,21 @@ void ConnectionHandlerImpl::SendEndService(uint32_t key, uint8_t service_type) { } } +bool ConnectionHandlerImpl::IsSessionHeartbeatTracked( + const uint32_t connection_key) const { + SDL_LOG_AUTO_TRACE(); + uint32_t connection_handle = 0; + uint8_t session_id = 0; + PairFromKey(connection_key, &connection_handle, &session_id); + + sync_primitives::AutoReadLock lock(connection_list_lock_); + ConnectionList::const_iterator it = connection_list_.find(connection_handle); + if (connection_list_.end() != it) { + return it->second->IsSessionHeartbeatTracked(session_id); + } + return false; +} + void ConnectionHandlerImpl::StartSessionHeartBeat(uint32_t connection_key) { SDL_LOG_AUTO_TRACE(); uint32_t connection_handle = 0; diff --git a/src/components/connection_handler/src/heartbeat_monitor.cc b/src/components/connection_handler/src/heartbeat_monitor.cc index f3e2da2696c..8e15c934b94 100644 --- a/src/components/connection_handler/src/heartbeat_monitor.cc +++ b/src/components/connection_handler/src/heartbeat_monitor.cc @@ -87,6 +87,13 @@ void HeartBeatMonitor::threadMain() { } void HeartBeatMonitor::AddSession(uint8_t session_id) { + if (0 == default_heartbeat_timeout_) { + SDL_LOG_INFO("Won't add session with id " + << static_cast(session_id) + << " because Heartbeat is disabled."); + return; + } + const uint32_t converted_session_id = static_cast(session_id); UNUSED(converted_session_id); SDL_LOG_DEBUG("Add session with id " << converted_session_id); @@ -96,6 +103,7 @@ void HeartBeatMonitor::AddSession(uint8_t session_id) { << " already exists"); return; } + sessions_.insert( std::make_pair(session_id, SessionState(default_heartbeat_timeout_))); SDL_LOG_INFO("Start heartbeat for session: " << converted_session_id); @@ -125,6 +133,14 @@ void HeartBeatMonitor::KeepAlive(uint8_t session_id) { } } +bool HeartBeatMonitor::IsSessionHeartbeatTracked( + const uint8_t session_id) const { + SDL_LOG_AUTO_TRACE(); + AutoLock auto_lock(sessions_list_lock_); + + return sessions_.end() != sessions_.find(session_id); +} + void HeartBeatMonitor::exitThreadMain() { // FIXME (dchmerev@luxoft.com): thread requested to stop should stop as soon // as possible, 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 9305eee2ee0..79b237253cd 100644 --- a/src/components/connection_handler/test/connection_handler_impl_test.cc +++ b/src/components/connection_handler/test/connection_handler_impl_test.cc @@ -56,6 +56,7 @@ using namespace ::connection_handler; using ::protocol_handler::ServiceType; using namespace ::protocol_handler; using ::testing::_; +using ::testing::An; using ::testing::ByRef; using ::testing::DoAll; using ::testing::InSequence; @@ -127,7 +128,8 @@ class ConnectionHandlerTest : public ::testing::Test { void AddTestSession() { protocol_handler_test::MockProtocolHandler temp_protocol_handler; connection_handler_->set_protocol_handler(&temp_protocol_handler); - EXPECT_CALL(temp_protocol_handler, NotifySessionStarted(_, _, _)) + EXPECT_CALL(temp_protocol_handler, + NotifySessionStarted(An(), _, _)) .WillOnce(SaveArg<0>(&out_context_)); connection_handler_->OnSessionStartedCallback( @@ -164,7 +166,8 @@ class ConnectionHandlerTest : public ::testing::Test { SessionContext context; protocol_handler_test::MockProtocolHandler temp_protocol_handler; connection_handler_->set_protocol_handler(&temp_protocol_handler); - EXPECT_CALL(temp_protocol_handler, NotifySessionStarted(_, _, _)) + EXPECT_CALL(temp_protocol_handler, + NotifySessionStarted(An(), _, _)) .WillOnce(SaveArg<0>(&context)); connection_handler_->OnSessionStartedCallback(uid_, @@ -371,7 +374,8 @@ TEST_F(ConnectionHandlerTest, StartSession_NoConnection) { protocol_handler::SessionContext context; connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, _, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), _, _)) .WillOnce(SaveArg<0>(&context)); connection_handler_->OnSessionStartedCallback( @@ -399,6 +403,10 @@ TEST_F(ConnectionHandlerTest, AddConnection_StopConnection) { } TEST_F(ConnectionHandlerTest, GetConnectionSessionsCount) { + ASSERT_TRUE(connection_handler_->getConnectionList().empty()); + EXPECT_EQ(0u, + connection_handler_->GetConnectionSessionsCount(connection_key_)); + AddTestDeviceConnection(); EXPECT_EQ(0u, connection_handler_->GetConnectionSessionsCount(connection_key_)); @@ -415,13 +423,19 @@ TEST_F(ConnectionHandlerTest, GetAppIdOnSessionKey) { uint32_t app_id = 0; const uint32_t test_id = SessionHash(uid_, out_context_.new_session_id_); - connection_handler::DeviceHandle* device_id = NULL; EXPECT_EQ(0, connection_handler_->GetDataOnSessionKey( - connection_key_, &app_id, NULL, device_id)); + connection_key_, &app_id, nullptr, nullptr)); EXPECT_EQ(test_id, app_id); } +TEST_F(ConnectionHandlerTest, GetAppIdOnSessionKey_InvalidConnectionId) { + uint8_t invalid_id = 0; + EXPECT_EQ(-1, + connection_handler_->GetDataOnSessionKey( + invalid_id, nullptr, nullptr, nullptr)); +} + TEST_F(ConnectionHandlerTest, GetAppIdOnSessionKey_SessionNotStarted) { AddTestDeviceConnection(); @@ -443,10 +457,21 @@ TEST_F(ConnectionHandlerTest, GetDeviceID) { const Device& devres = pos->second; std::string test_mac_address = devres.mac_address(); + std::string invalid_mac_address; + EXPECT_FALSE( + connection_handler_->GetDeviceID(invalid_mac_address, &test_handle)); + EXPECT_TRUE(connection_handler_->GetDeviceID(test_mac_address, &test_handle)); EXPECT_EQ(device_handle_, test_handle); } +TEST_F(ConnectionHandlerTest, GetDataOnDeviceID_InvalidDeviceHandle) { + const DeviceHandle handle = 0; + EXPECT_EQ(-1, + connection_handler_->GetDataOnDeviceID( + handle, nullptr, nullptr, nullptr, nullptr)); +} + TEST_F(ConnectionHandlerTest, GetDeviceName) { AddTestDeviceConnection(); AddTestSession(); @@ -466,7 +491,7 @@ TEST_F(ConnectionHandlerTest, GetConnectionType) { std::string test_connection_type; EXPECT_EQ(0, connection_handler_->GetDataOnDeviceID( - handle, NULL, NULL, NULL, &test_connection_type)); + handle, nullptr, nullptr, nullptr, &test_connection_type)); EXPECT_EQ(connection_type_, test_connection_type); } @@ -487,7 +512,7 @@ TEST_F(ConnectionHandlerTest, GetApplicationsOnDevice) { EXPECT_EQ(test_id, applications_list.front()); } -TEST_F(ConnectionHandlerTest, GetDefaultProtocolVersion) { +TEST_F(ConnectionHandlerTest, ProtocolVersionUsed_Default_Success) { AddTestDeviceConnection(); AddTestSession(); @@ -498,7 +523,7 @@ TEST_F(ConnectionHandlerTest, GetDefaultProtocolVersion) { EXPECT_EQ(PROTOCOL_VERSION_2, protocol_version); } -TEST_F(ConnectionHandlerTest, GetProtocolVersion) { +TEST_F(ConnectionHandlerTest, ProtocolVersionUsed_Success) { AddTestDeviceConnection(); AddTestSession(); ChangeProtocol(uid_, out_context_.new_session_id_, PROTOCOL_VERSION_3); @@ -510,7 +535,7 @@ TEST_F(ConnectionHandlerTest, GetProtocolVersion) { EXPECT_EQ(PROTOCOL_VERSION_3, protocol_version); } -TEST_F(ConnectionHandlerTest, GetProtocolVersionAfterBinding) { +TEST_F(ConnectionHandlerTest, ProtocolVersionUsed_AfterBinding_Success) { AddTestDeviceConnection(); AddTestSession(); uint8_t protocol_version = 0; @@ -526,6 +551,15 @@ TEST_F(ConnectionHandlerTest, GetProtocolVersionAfterBinding) { EXPECT_EQ(PROTOCOL_VERSION_3, protocol_version); } +TEST_F(ConnectionHandlerTest, ProtocolVersionUsed_WrongConnection_Fail) { + AddTestDeviceConnection(); + AddTestSession(); + uint8_t connection_id = 0; + uint8_t protocol_version = 0; + EXPECT_FALSE(connection_handler_->ProtocolVersionUsed( + connection_id, out_context_.new_session_id_, protocol_version)); +} + TEST_F(ConnectionHandlerTest, GetPairFromKey) { AddTestDeviceConnection(); AddTestSession(); @@ -544,14 +578,25 @@ MATCHER_P(SameDevice, device, "") { arg.connection_type() == device.connection_type(); } -TEST_F(ConnectionHandlerTest, IsHeartBeatSupported) { +TEST_F(ConnectionHandlerTest, IsHeartBeatSupported_Success) { AddTestDeviceConnection(); AddTestSession(); ChangeProtocol(uid_, out_context_.new_session_id_, PROTOCOL_VERSION_3); + EXPECT_TRUE(connection_handler_->IsHeartBeatSupported( uid_, out_context_.new_session_id_)); } +TEST_F(ConnectionHandlerTest, IsHeartBeatSupported_Fail) { + AddTestDeviceConnection(); + AddTestSession(); + ChangeProtocol(uid_, out_context_.new_session_id_, PROTOCOL_VERSION_3); + + uint8_t invalid_id = 0u; + EXPECT_FALSE(connection_handler_->IsHeartBeatSupported( + invalid_id, out_context_.new_session_id_)); +} + TEST_F(ConnectionHandlerTest, SendEndServiceWithoutSetProtocolHandler) { AddTestDeviceConnection(); AddTestSession(); @@ -559,6 +604,12 @@ TEST_F(ConnectionHandlerTest, SendEndServiceWithoutSetProtocolHandler) { connection_handler_->SendEndService(connection_key_, kRpc); } +TEST_F(ConnectionHandlerTest, SendEndService_NoSession_Fail) { + AddTestDeviceConnection(); + EXPECT_CALL(mock_protocol_handler_, SendEndService(_, _, _, kRpc)).Times(0); + connection_handler_->SendEndService(connection_key_, kRpc); +} + TEST_F(ConnectionHandlerTest, SendEndService) { AddTestDeviceConnection(); AddTestSession(); @@ -838,7 +889,27 @@ TEST_F(ConnectionHandlerTest, OnDeviceRemoved_ServiceStarted) { connection_handler_->OnDeviceRemoved(device1); } -TEST_F(ConnectionHandlerTest, OnConnectionClosed) { +TEST_F(ConnectionHandlerTest, OnConnectionClosed_InvalidConnectionId_Fail) { + AddTestDeviceConnection(); + AddTestSession(); + + connection_handler_test::MockConnectionHandlerObserver + mock_connection_handler_observer; + connection_handler_->set_connection_handler_observer( + &mock_connection_handler_observer); + + EXPECT_CALL(mock_connection_handler_observer, + OnServiceEndedCallback(connection_key_, kBulk, kCommon)) + .Times(0); + EXPECT_CALL(mock_connection_handler_observer, + OnServiceEndedCallback(connection_key_, kRpc, kCommon)) + .Times(0); + + uint8_t invalid_id = 0; + connection_handler_->OnConnectionClosed(invalid_id); +} + +TEST_F(ConnectionHandlerTest, OnConnectionClosed_Success) { AddTestDeviceConnection(); AddTestSession(); @@ -978,34 +1049,34 @@ TEST_F(ConnectionHandlerTest, CloseSessionWithCommonReason) { connection_handler_->set_protocol_handler(&mock_protocol_handler_); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; EXPECT_CALL(mock_protocol_handler_, SendEndSession(uid_, out_context_.new_session_id_)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; InSequence seq; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kMobileNav, kCommon)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kAudio, kCommon)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kBulk, kCommon)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kRpc, kCommon)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; connection_handler_->CloseSession(connection_key_, kCommon); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } TEST_F(ConnectionHandlerTest, CloseSessionWithFloodReason) { @@ -1020,34 +1091,34 @@ TEST_F(ConnectionHandlerTest, CloseSessionWithFloodReason) { connection_handler_->set_protocol_handler(&mock_protocol_handler_); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; EXPECT_CALL(mock_protocol_handler_, SendEndSession(uid_, out_context_.new_session_id_)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; InSequence seq; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kMobileNav, kFlood)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kAudio, kFlood)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kBulk, kFlood)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kRpc, kFlood)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; connection_handler_->CloseSession(connection_key_, kFlood); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } TEST_F(ConnectionHandlerTest, CloseSessionWithMalformedMessage) { @@ -1062,7 +1133,7 @@ TEST_F(ConnectionHandlerTest, CloseSessionWithMalformedMessage) { connection_handler_->set_protocol_handler(&mock_protocol_handler_); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; EXPECT_CALL(mock_protocol_handler_, SendEndSession(uid_, out_context_.new_session_id_)) @@ -1071,24 +1142,24 @@ TEST_F(ConnectionHandlerTest, CloseSessionWithMalformedMessage) { InSequence seq; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kMobileNav, kMalformed)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kAudio, kMalformed)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kBulk, kMalformed)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kRpc, kMalformed)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; connection_handler_->CloseSession(connection_key_, kMalformed); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } TEST_F(ConnectionHandlerTest, CloseConnectionSessionsWithMalformedMessage) { @@ -1103,7 +1174,7 @@ TEST_F(ConnectionHandlerTest, CloseConnectionSessionsWithMalformedMessage) { connection_handler_->set_protocol_handler(&mock_protocol_handler_); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; EXPECT_CALL(mock_protocol_handler_, SendEndSession(uid_, out_context_.new_session_id_)) @@ -1112,24 +1183,42 @@ TEST_F(ConnectionHandlerTest, CloseConnectionSessionsWithMalformedMessage) { InSequence seq; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kMobileNav, kMalformed)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kAudio, kMalformed)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kBulk, kMalformed)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kRpc, kMalformed)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; connection_handler_->CloseConnectionSessions(uid_, kMalformed); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); +} + +TEST_F(ConnectionHandlerTest, CloseConnectionSessionsInvalidConnectionId) { + connection_handler_test::MockConnectionHandlerObserver + mock_connection_handler_observer; + connection_handler_->set_connection_handler_observer( + &mock_connection_handler_observer); + + connection_handler_->set_protocol_handler(&mock_protocol_handler_); + + EXPECT_CALL(mock_protocol_handler_, SendEndSession(_, _)).Times(0); + EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(_, _, _)) + .Times(0); + EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(_, _, _)) + .Times(0); + + uint8_t invalid_id = 0u; + connection_handler_->CloseConnectionSessions(invalid_id, kCommon); } TEST_F(ConnectionHandlerTest, CloseConnectionSessionsWithCommonReason) { @@ -1144,34 +1233,34 @@ TEST_F(ConnectionHandlerTest, CloseConnectionSessionsWithCommonReason) { connection_handler_->set_protocol_handler(&mock_protocol_handler_); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; EXPECT_CALL(mock_protocol_handler_, SendEndSession(uid_, out_context_.new_session_id_)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; InSequence seq; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kMobileNav, kCommon)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kAudio, kCommon)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kBulk, kCommon)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_connection_handler_observer, OnServiceEndedCallback(connection_key_, kRpc, kCommon)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; connection_handler_->CloseConnectionSessions(uid_, kCommon); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } TEST_F(ConnectionHandlerTest, StartService_withServices) { @@ -1183,7 +1272,8 @@ TEST_F(ConnectionHandlerTest, StartService_withServices) { SessionContext audio_context, video_context; connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, _, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), _, _)) .WillOnce(SaveArg<0>(&audio_context)) .WillOnce(SaveArg<0>(&video_context)); @@ -1224,7 +1314,8 @@ TEST_F(ConnectionHandlerTest, StartService_withServices_withParams) { std::vector empty; BsonObject* dummy_param = reinterpret_cast(&dummy); connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, empty, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), empty, _)) .WillOnce(SaveArg<0>(&video_context)); connection_handler_->OnSessionStartedCallback(uid_, @@ -1269,7 +1360,8 @@ TEST_F(ConnectionHandlerTest, ServiceStop) { SessionContext audio_context; connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, _, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), _, _)) .WillRepeatedly(SaveArg<0>(&audio_context)); // Check ignoring hash_id on stop non-rpc service @@ -1360,7 +1452,8 @@ TEST_F(ConnectionHandlerTest, SessionStarted_WithRpc) { reason)); connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, _, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), _, _)) .WillOnce(SaveArg<0>(&out_context_)); // Start new session with RPC service @@ -1400,7 +1493,8 @@ TEST_F(ConnectionHandlerTest, ServiceStarted_Video_SUCCESS) { // confirm that NotifySessionStarted() is called connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, empty, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), empty, _)) .WillOnce(SaveArg<0>(&out_context_)); connection_handler_->OnSessionStartedCallback(uid_, @@ -1442,7 +1536,8 @@ TEST_F(ConnectionHandlerTest, ServiceStarted_Video_FAILURE) { // confirm that NotifySessionStarted() is called connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, empty, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), empty, _)) .WillOnce(SaveArg<0>(&out_context_)); connection_handler_->OnSessionStartedCallback(uid_, @@ -1451,7 +1546,7 @@ TEST_F(ConnectionHandlerTest, ServiceStarted_Video_FAILURE) { PROTECTION_OFF, dummy_params); - EXPECT_EQ(0u, out_context_.new_session_id_); + EXPECT_TRUE(out_context_.is_start_session_failed_); } /* @@ -1466,7 +1561,8 @@ TEST_F(ConnectionHandlerTest, ServiceStarted_Video_Multiple) { protocol_handler_test::MockProtocolHandler temp_protocol_handler; connection_handler_->set_protocol_handler(&temp_protocol_handler); - EXPECT_CALL(temp_protocol_handler, NotifySessionStarted(_, _, _)) + EXPECT_CALL(temp_protocol_handler, + NotifySessionStarted(An(), _, _)) .WillOnce(SaveArg<0>(&context_first)) .WillOnce(SaveArg<0>(&context_second)); @@ -1537,7 +1633,8 @@ TEST_F(ConnectionHandlerTest, ServiceStarted_Video_Multiple) { // verify that connection handler will not mix up the two results SessionContext new_context_first, new_context_second; connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, empty, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), empty, _)) .WillOnce(SaveArg<0>(&new_context_second)) .WillOnce(SaveArg<0>(&new_context_first)); @@ -1552,8 +1649,10 @@ TEST_F(ConnectionHandlerTest, ServiceStarted_Video_Multiple) { PROTECTION_OFF, dummy_params); - EXPECT_NE(0u, new_context_first.new_session_id_); // result is positive - EXPECT_EQ(0u, new_context_second.new_session_id_); // result is negative + EXPECT_FALSE( + new_context_first.is_start_session_failed_); // result is positive + EXPECT_TRUE( + new_context_second.is_start_session_failed_); // result is negative } TEST_F(ConnectionHandlerTest, @@ -1569,7 +1668,8 @@ TEST_F(ConnectionHandlerTest, SessionContext fail_context; SessionContext positive_context; connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, _, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), _, _)) .WillOnce(SaveArg<0>(&fail_context)) .WillOnce(SaveArg<0>(&positive_context)); @@ -1612,7 +1712,8 @@ TEST_F(ConnectionHandlerTest, SessionContext fail_context; SessionContext positive_context; connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, _, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), _, _)) .WillOnce(SaveArg<0>(&fail_context)) .WillOnce(SaveArg<0>(&positive_context)); @@ -1657,7 +1758,8 @@ TEST_F(ConnectionHandlerTest, SessionContext context_first, context_second; connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, _, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), _, _)) .WillOnce(SaveArg<0>(&context_first)) .WillOnce(SaveArg<0>(&context_second)); @@ -1712,7 +1814,8 @@ TEST_F(ConnectionHandlerTest, SessionContext rejected_context, positive_context; connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, _, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), _, _)) .WillOnce(SaveArg<0>(&rejected_context)) .WillOnce(SaveArg<0>(&positive_context)); @@ -1747,7 +1850,7 @@ TEST_F(ConnectionHandlerTest, #endif // ENABLE_SECURITY } -TEST_F(ConnectionHandlerTest, SessionStarted_DealyProtect) { +TEST_F(ConnectionHandlerTest, SessionStarted_DelayProtect) { AddTestDeviceConnection(); AddTestSession(); ChangeProtocol( @@ -1755,7 +1858,8 @@ TEST_F(ConnectionHandlerTest, SessionStarted_DealyProtect) { SessionContext context_new, context_second, context_third; connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, _, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), _, _)) .WillOnce(SaveArg<0>(&context_new)) .WillOnce(SaveArg<0>(&context_second)) .WillOnce(SaveArg<0>(&context_third)); @@ -1804,13 +1908,14 @@ TEST_F(ConnectionHandlerTest, SessionStarted_DealyProtect) { #endif // ENABLE_SECURITY } -TEST_F(ConnectionHandlerTest, SessionStarted_DealyProtectBulk) { +TEST_F(ConnectionHandlerTest, SessionStarted_DelayProtectBulk) { AddTestDeviceConnection(); AddTestSession(); SessionContext new_context; connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, _, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), _, _)) .WillOnce(SaveArg<0>(&new_context)); connection_handler_->OnSessionStartedCallback(uid_, out_context_.new_session_id_, @@ -1916,7 +2021,8 @@ TEST_F(ConnectionHandlerTest, GetSSLContext_ByProtectedService) { SessionContext new_context; connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, _, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), _, _)) .WillOnce(SaveArg<0>(&new_context)); // Open kAudio service @@ -1953,7 +2059,8 @@ TEST_F(ConnectionHandlerTest, GetSSLContext_ByDealyProtectedRPC) { SessionContext new_context; connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, _, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), _, _)) .WillOnce(SaveArg<0>(&new_context)); // Protect kRpc (Bulk will be protect also) @@ -1993,7 +2100,8 @@ TEST_F(ConnectionHandlerTest, GetSSLContext_ByDealyProtectedBulk) { SessionContext new_context; connection_handler_->set_protocol_handler(&mock_protocol_handler_); - EXPECT_CALL(mock_protocol_handler_, NotifySessionStarted(_, _, _)) + EXPECT_CALL(mock_protocol_handler_, + NotifySessionStarted(An(), _, _)) .WillOnce(SaveArg<0>(&new_context)); // Protect Bulk (kRpc will be protected also) @@ -2095,6 +2203,25 @@ TEST_F(ConnectionHandlerTest, OnDeviceConnectionSwitching) { OnDeviceSwitchingStart(SameDevice(d1), SameDevice(d2))); connection_handler_->OnDeviceSwitchingStart(mac_address_, second_mac_address); + + EXPECT_CALL(mock_connection_handler_observer, + OnDeviceSwitchingFinish(encryption::MakeHash(mac_address_))); + connection_handler_->OnDeviceSwitchingFinish(mac_address_); + + EXPECT_CALL( + mock_connection_handler_observer, + OnDeviceSwitchingFinish(encryption::MakeHash(second_mac_address))); + connection_handler_->OnDeviceSwitchingFinish(second_mac_address); +} + +TEST_F(ConnectionHandlerTest, OnConnectionEstablishedForUnknownDevice) { + const transport_manager::DeviceInfo device_info( + device_handle_, mac_address_, device_name_, std::string("WIFI")); + const transport_manager::ConnectionUID uid = 2u; + + connection_handler_->OnConnectionEstablished(device_info, uid); + ASSERT_TRUE(connection_handler_->getDeviceList().empty()); + ASSERT_TRUE(connection_handler_->getConnectionList().empty()); } TEST_F(ConnectionHandlerTest, StartStopSecondarySession) { @@ -2200,6 +2327,13 @@ TEST_F(ConnectionHandlerTest, StopSecondarySession_NoService) { EXPECT_EQ(st.secondary_transport, 0u); } +TEST_F(ConnectionHandlerTest, GetSessionTransports_InvalidSessionId) { + uint8_t invalid_id = 0; + SessionTransports st = connection_handler_->GetSessionTransports(invalid_id); + EXPECT_EQ(st.primary_transport, 0u); + EXPECT_EQ(st.secondary_transport, 0u); +} + TEST_F(ConnectionHandlerTest, ConnectionType_valid) { AddTestDeviceConnection(); AddTestSession(); @@ -2289,6 +2423,46 @@ TEST_F(ConnectionHandlerTest, SetSecondaryTransportID_Failure) { EXPECT_EQ(0u, st.secondary_transport); } +TEST_F(ConnectionHandlerTest, CloseSession_TwoSessions_ConnectionOpened) { + // Add virtual device and connection + AddTestDeviceConnection(); + AddTestSession(); + + connection_handler::ConnectionList& connection_list = + connection_handler_->getConnectionList(); + ASSERT_EQ(1u, connection_list.size()); + + connection_handler::Connection* connection = connection_list.begin()->second; + EXPECT_EQ(1u, connection->session_map().size()); + + AddTestSession(); + EXPECT_EQ(2u, connection->session_map().size()); + + connection_handler_->CloseSession( + uid_, out_context_.new_session_id_, kCommon); + + EXPECT_EQ(1u, connection->session_map().size()); + EXPECT_EQ(1u, connection_list.size()); +} + +TEST_F(ConnectionHandlerTest, CloseSession_LastSession_ConnectionOpened) { + // Add virtual device and connection + AddTestDeviceConnection(); + AddTestSession(); + + connection_handler::ConnectionList& connection_list = + connection_handler_->getConnectionList(); + ASSERT_EQ(1u, connection_list.size()); + + connection_handler::Connection* connection = connection_list.begin()->second; + EXPECT_EQ(1u, connection->session_map().size()); + + connection_handler_->CloseSession( + uid_, out_context_.new_session_id_, kCommon); + + EXPECT_EQ(0u, connection->session_map().size()); + EXPECT_EQ(1u, connection_list.size()); +} } // namespace connection_handler_test } // namespace components } // namespace test diff --git a/src/components/connection_handler/test/connection_test.cc b/src/components/connection_handler/test/connection_test.cc index dd86831225c..9896142cefc 100644 --- a/src/components/connection_handler/test/connection_test.cc +++ b/src/components/connection_handler/test/connection_test.cc @@ -62,24 +62,27 @@ using ::testing::Return; class ConnectionTest : public ::testing::Test { protected: void SetUp() OVERRIDE { - connection_handler_ = new ConnectionHandlerImpl( - mock_connection_handler_settings, transport_manager_mock); + connection_handler_.reset(new ConnectionHandlerImpl( + mock_connection_handler_settings, transport_manager_mock)); const ConnectionHandle connectionHandle = 0; const DeviceHandle device_handle = 0u; const uint32_t heart_beat = 10000u; - connection_ = new Connection( - connectionHandle, device_handle, connection_handler_, heart_beat); + connection_.reset(new Connection(connectionHandle, + device_handle, + connection_handler_.get(), + heart_beat)); } void TearDown() OVERRIDE { - delete connection_; - delete connection_handler_; + connection_.reset(); + connection_handler_.reset(); } void StartSession() { StartDefaultSession(); connection_->UpdateProtocolVersionSession( session_id, protocol_handler::PROTOCOL_VERSION_3); } + void StartDefaultSession() { session_id = connection_->AddNewSession(kDefaultConnectionHandle); EXPECT_NE(session_id, 0u); @@ -93,6 +96,7 @@ class ConnectionTest : public ::testing::Test { EXPECT_TRUE(found_result); EXPECT_EQ(connection_->primary_connection_handle(), 0); } + void AddNewService(const ServiceType service_type, const bool protection, const bool expect_add_new_service_call_result, @@ -124,6 +128,7 @@ class ConnectionTest : public ::testing::Test { #endif // ENABLE_SECURITY } } + void AddNewSecondaryService(const ServiceType service_type) { const bool result = connection_->AddNewService( session_id, service_type, false, kSecondaryConnectionHandle); @@ -162,11 +167,11 @@ class ConnectionTest : public ::testing::Test { EXPECT_EQ(expect_exist_service, found_result); } - Connection* connection_; + std::shared_ptr connection_; MockConnectionHandlerSettings mock_connection_handler_settings; testing::StrictMock transport_manager_mock; - ConnectionHandlerImpl* connection_handler_; + std::shared_ptr connection_handler_; uint32_t session_id; static const transport_manager::ConnectionUID kDefaultConnectionHandle = 1; static const transport_manager::ConnectionUID kSecondaryConnectionHandle = 2; @@ -191,19 +196,24 @@ TEST_F(ConnectionTest, Session_UpdateProtocolVersion) { EXPECT_EQ(static_cast(PROTOCOL_VERSION_3), protocol_version); } -TEST_F(ConnectionTest, HeartBeat_NotSupported) { - // Arrange +TEST_F(ConnectionTest, SupportHeartBeat_WrongSessionId_Fail) { + uint8_t fake_id = 0u; + const SessionMap session_map = connection_->session_map(); + EXPECT_TRUE(session_map.empty()); + + EXPECT_FALSE(connection_->SupportHeartBeat(fake_id)); +} + +TEST_F(ConnectionTest, SupportHeartBeat_NotSupported_Fail) { StartDefaultSession(); uint8_t protocol_version; EXPECT_TRUE(connection_->ProtocolVersion(session_id, protocol_version)); EXPECT_EQ(static_cast(PROTOCOL_VERSION_2), protocol_version); - // Assert EXPECT_FALSE(connection_->SupportHeartBeat(session_id)); } -TEST_F(ConnectionTest, HeartBeat_Protocol3_Supported) { - // Arrange +TEST_F(ConnectionTest, SupportHeartBeat_Protocol3_Success) { StartSession(); // Check execution if protocol version is 3 const uint8_t protocol_version = static_cast(PROTOCOL_VERSION_3); @@ -211,8 +221,7 @@ TEST_F(ConnectionTest, HeartBeat_Protocol3_Supported) { EXPECT_TRUE(connection_->SupportHeartBeat(session_id)); } -TEST_F(ConnectionTest, HeartBeat_Protocol4_PositiveHeartBeat_Supported) { - // Arrange +TEST_F(ConnectionTest, SupportHeartBeat_Protocol4_PositiveHeartBeat_Success) { StartSession(); // Check execution if protocol version is 4 const uint8_t protocol_version = static_cast(PROTOCOL_VERSION_4); @@ -220,16 +229,12 @@ TEST_F(ConnectionTest, HeartBeat_Protocol4_PositiveHeartBeat_Supported) { EXPECT_TRUE(connection_->SupportHeartBeat(session_id)); } -TEST_F(ConnectionTest, HeartBeat_Protocol4_ZeroHeartBeat_NotSupported) { - // Correctc of connection (need connection with heartbeat=0) - delete connection_; - connection_ = 0; - +TEST_F(ConnectionTest, SupportHeartBeat_Protocol4_ZeroHeartBeat_Fail) { const ConnectionHandle connectionHandle = 0; const DeviceHandle device_handle = 0u; const uint32_t heart_beat = 0u; - connection_ = new Connection( - connectionHandle, device_handle, connection_handler_, heart_beat); + connection_.reset(new Connection( + connectionHandle, device_handle, connection_handler_.get(), heart_beat)); StartSession(); // Check execution if protocol version is 4 const uint8_t protocol_version = static_cast(PROTOCOL_VERSION_4); @@ -237,8 +242,7 @@ TEST_F(ConnectionTest, HeartBeat_Protocol4_ZeroHeartBeat_NotSupported) { EXPECT_FALSE(connection_->SupportHeartBeat(session_id)); } -TEST_F(ConnectionTest, HeartBeat_Protocol5_PositiveHeartBeat_Supported) { - // Arrange +TEST_F(ConnectionTest, SupportHeartBeat_Protocol5_PositiveHeartBeat_Success) { StartSession(); // Check execution if protocol version is 5 const uint8_t protocol_version = static_cast(PROTOCOL_VERSION_5); @@ -246,16 +250,12 @@ TEST_F(ConnectionTest, HeartBeat_Protocol5_PositiveHeartBeat_Supported) { EXPECT_TRUE(connection_->SupportHeartBeat(session_id)); } -TEST_F(ConnectionTest, HeartBeat_Protocol5_ZeroHeartBeat_NotSupported) { - // Correctc of connection (need connection with heartbeat=0) - delete connection_; - connection_ = 0; - +TEST_F(ConnectionTest, SupportHeartBeat_Protocol5_ZeroHeartBeat_Fail) { const ConnectionHandle connectionHandle = 0; const DeviceHandle device_handle = 0u; const uint32_t heart_beat = 0u; - connection_ = new Connection( - connectionHandle, device_handle, connection_handler_, heart_beat); + connection_.reset(new Connection( + connectionHandle, device_handle, connection_handler_.get(), heart_beat)); StartSession(); // Check execution if protocol version is 5 const uint8_t protocol_version = static_cast(PROTOCOL_VERSION_5); @@ -304,6 +304,16 @@ TEST_F(ConnectionTest, Session_AddControlService) { kControl, PROTECTION_ON, EXPECT_RETURN_FALSE, EXPECT_SERVICE_NOT_EXISTS); } +TEST_F(ConnectionTest, AddNewService_NotSupported) { + StartDefaultSession(); + uint8_t protocol_version; + EXPECT_TRUE(connection_->ProtocolVersion(session_id, protocol_version)); + EXPECT_EQ(static_cast(PROTOCOL_VERSION_2), protocol_version); + + EXPECT_FALSE(connection_->AddNewService( + session_id, kAudio, false, kDefaultConnectionHandle)); +} + // Invalid Services couldnot be started anyway TEST_F(ConnectionTest, Session_AddInvalidService) { StartSession(); @@ -358,13 +368,11 @@ TEST_F(ConnectionTest, Session_AddAllOtherService_Protected) { TEST_F(ConnectionTest, FindAddedService) { StartSession(); - // Arrange SessionMap currentSessionMap = connection_->session_map(); Service* sessionWithService = currentSessionMap.find(session_id)->second.FindService(kAudio); EXPECT_EQ(NULL, sessionWithService); - // Act AddNewService( kAudio, PROTECTION_OFF, EXPECT_RETURN_TRUE, EXPECT_SERVICE_EXISTS); @@ -448,8 +456,8 @@ TEST_F(ConnectionTest, AddNewSession_VerifyAddSessionCalled) { ConnectionHandle connection_handle = 123; DeviceHandle device_handle = 0u; uint32_t heart_beat = 10000u; - Connection* connection = new Connection( - connection_handle, device_handle, &mock_connection_handler, heart_beat); + std::unique_ptr connection(new Connection( + connection_handle, device_handle, &mock_connection_handler, heart_beat)); transport_manager::ConnectionUID connection_handle_uid = 1; uint32_t mock_session_id = 2; @@ -461,7 +469,6 @@ TEST_F(ConnectionTest, AddNewSession_VerifyAddSessionCalled) { EXPECT_CALL(mock_connection_handler, RemoveSession(mock_session_id)) .WillOnce(Return(true)); // invoked by destructor of connection - delete connection; } TEST_F(ConnectionTest, RemoveSession_VerifyRemoveSessionCalled) { @@ -470,8 +477,8 @@ TEST_F(ConnectionTest, RemoveSession_VerifyRemoveSessionCalled) { ConnectionHandle connection_handle = 123; DeviceHandle device_handle = 0u; uint32_t heart_beat = 10000u; - Connection* connection = new Connection( - connection_handle, device_handle, &mock_connection_handler, heart_beat); + std::unique_ptr connection(new Connection( + connection_handle, device_handle, &mock_connection_handler, heart_beat)); transport_manager::ConnectionUID connection_handle_uid = 1; uint32_t mock_session_id = 10; @@ -486,7 +493,9 @@ TEST_F(ConnectionTest, RemoveSession_VerifyRemoveSessionCalled) { uint32_t ret = connection->RemoveSession(sid); EXPECT_EQ(sid, ret); - delete connection; + EXPECT_CALL(mock_connection_handler, RemoveSession(mock_session_id)) + .WillOnce(Return(true)); + EXPECT_EQ(0u, connection->RemoveSession(mock_session_id)); } TEST_F(ConnectionTest, SecondarySessionTest) { @@ -497,8 +506,8 @@ TEST_F(ConnectionTest, SecondarySessionTest) { const ConnectionHandle connectionHandle = 0; const DeviceHandle device_handle = 0u; const uint32_t heart_beat = 0u; - Connection* secondary_connection = new Connection( - connectionHandle, device_handle, connection_handler_, heart_beat); + std::unique_ptr secondary_connection(new Connection( + connectionHandle, device_handle, connection_handler_.get(), heart_beat)); secondary_connection->SetPrimaryConnectionHandle(kDefaultConnectionHandle); connection_handler::ConnectionHandle expected_primary_connection_handle = @@ -508,8 +517,6 @@ TEST_F(ConnectionTest, SecondarySessionTest) { AddNewSecondaryService(kAudio); AddNewSecondaryService(kMobileNav); - - delete secondary_connection; } TEST_F(ConnectionTest, RemoveSecondaryServices_SUCCESS) { @@ -607,7 +614,7 @@ TEST_F(ConnectionTest, SetGetSSLContext) { TEST_F(ConnectionTest, SetProtectionFlagForRPC) { StartSession(); - // Arrange + SessionMap currentSessionMap = connection_->session_map(); Service* service_rpc = currentSessionMap.find(session_id)->second.FindService(kRpc); @@ -631,7 +638,7 @@ TEST_F(ConnectionTest, SetProtectionFlagForRPC) { TEST_F(ConnectionTest, SetProtectionFlagForBulk) { StartSession(); - // Arrange + SessionMap currentSessionMap = connection_->session_map(); Service* service_rpc = currentSessionMap.find(session_id)->second.FindService(kRpc); 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 d7362551348..2ca8a461842 100644 --- a/src/components/connection_handler/test/heart_beat_monitor_test.cc +++ b/src/components/connection_handler/test/heart_beat_monitor_test.cc @@ -123,19 +123,19 @@ TEST_F(HeartBeatMonitorTest, TimerElapsed) { const uint32_t session = connection_->AddNewSession(kDefaultConnectionHandle); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; EXPECT_CALL(connection_handler_mock_, CloseSession(_, session, _)) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), RemoveSession(connection_, session))); times++; EXPECT_CALL(connection_handler_mock_, SendHeartBeat(_, session)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; connection_->StartHeartBeat(session); - EXPECT_TRUE(waiter.WaitFor( + EXPECT_TRUE(waiter->WaitFor( times, 2 * timeout_ * MICROSECONDS_IN_MILLISECONDS + MICROSECONDS_IN_SECOND)); } @@ -166,13 +166,13 @@ TEST_F(HeartBeatMonitorTest, NotKeptAlive) { const uint32_t session = connection_->AddNewSession(kDefaultConnectionHandle); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; EXPECT_CALL(connection_handler_mock_, SendHeartBeat(_, session)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(connection_handler_mock_, CloseSession(_, session, _)) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), RemoveSession(connection_, session))); times++; @@ -180,7 +180,7 @@ TEST_F(HeartBeatMonitorTest, NotKeptAlive) { usleep(timeout_); connection_->KeepAlive(session); - EXPECT_TRUE(waiter.WaitFor( + EXPECT_TRUE(waiter->WaitFor( times, 2 * timeout_ * MICROSECONDS_IN_MILLISECONDS + MICROSECONDS_IN_SECOND)); } @@ -203,28 +203,28 @@ TEST_F(HeartBeatMonitorTest, TwoSessionsElapsed) { const uint32_t kSession2 = connection_->AddNewSession(kAnotherConnectionHandle); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; EXPECT_CALL(connection_handler_mock_, CloseSession(_, kSession1, _)) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), RemoveSession(connection_, kSession1))); times++; EXPECT_CALL(connection_handler_mock_, CloseSession(_, kSession2, _)) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), RemoveSession(connection_, kSession2))); times++; EXPECT_CALL(connection_handler_mock_, SendHeartBeat(_, kSession1)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(connection_handler_mock_, SendHeartBeat(_, kSession2)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; connection_->StartHeartBeat(kSession1); connection_->StartHeartBeat(kSession2); - EXPECT_TRUE(waiter.WaitFor( + EXPECT_TRUE(waiter->WaitFor( times, 2 * timeout_ * MICROSECONDS_IN_MILLISECONDS + MICROSECONDS_IN_SECOND)); } @@ -256,21 +256,21 @@ TEST_F(HeartBeatMonitorTest, DecreaseHeartBeatTimeout) { const uint32_t kSession = connection_->AddNewSession(kDefaultConnectionHandle); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; EXPECT_CALL(connection_handler_mock_, CloseSession(_, kSession, _)) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), RemoveSession(connection_, kSession))); times++; EXPECT_CALL(connection_handler_mock_, SendHeartBeat(_, kSession)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; const uint32_t new_timeout = timeout_ - kTime_offset; connection_->StartHeartBeat(kSession); connection_->SetHeartBeatTimeout(new_timeout, kSession); - EXPECT_TRUE(waiter.WaitFor( + EXPECT_TRUE(waiter->WaitFor( times, 2 * timeout_ * MICROSECONDS_IN_MILLISECONDS + MICROSECONDS_IN_SECOND)); } 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 67a46aca56c..693b72eb505 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 @@ -36,7 +36,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include #include #include #include @@ -87,7 +86,6 @@ class CMessageBrokerController; class WebsocketSession : public std::enable_shared_from_this { boost::beast::websocket::stream ws_; - boost::asio::strand strand_; boost::beast::multi_buffer buffer_; boost::beast::multi_buffer send_buffer_; CMessageBrokerController* controller_; @@ -189,7 +187,6 @@ class WebsocketSession : public std::enable_shared_from_this { WebsocketSession& handler_; sync_primitives::Lock queue_lock_; sync_primitives::ConditionalVariable queue_new_items_; - std::atomic_bool write_pending_; std::atomic_bool shutdown_; sync_primitives::Lock write_lock_; diff --git a/src/components/hmi_message_handler/src/websocket_session.cc b/src/components/hmi_message_handler/src/websocket_session.cc index a387b639a29..6e1c4b9bc4e 100644 --- a/src/components/hmi_message_handler/src/websocket_session.cc +++ b/src/components/hmi_message_handler/src/websocket_session.cc @@ -41,7 +41,6 @@ SDL_CREATE_LOG_VARIABLE("HMIMessageHandler") WebsocketSession::WebsocketSession(boost::asio::ip::tcp::socket socket, CMessageBrokerController* controller) : ws_(std::move(socket)) - , strand_(ws_.get_executor()) , controller_(controller) , stop(false) , m_receivingBuffer("") @@ -57,10 +56,8 @@ WebsocketSession::WebsocketSession(boost::asio::ip::tcp::socket socket, WebsocketSession::~WebsocketSession() {} void WebsocketSession::Accept() { - ws_.async_accept(boost::asio::bind_executor( - strand_, - std::bind( - &WebsocketSession::Recv, shared_from_this(), std::placeholders::_1))); + ws_.async_accept(std::bind( + &WebsocketSession::Recv, shared_from_this(), std::placeholders::_1)); } void WebsocketSession::Shutdown() { @@ -90,11 +87,10 @@ void WebsocketSession::Recv(boost::system::error_code ec) { } ws_.async_read(buffer_, - boost::asio::bind_executor(strand_, - std::bind(&WebsocketSession::Read, - shared_from_this(), - std::placeholders::_1, - std::placeholders::_2))); + std::bind(&WebsocketSession::Read, + shared_from_this(), + std::placeholders::_1, + std::placeholders::_2)); } void WebsocketSession::Send(const std::string& message, 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 c9ad49efed5..a750bc236b5 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 @@ -175,11 +175,11 @@ TEST_F(HMIMessageHandlerImplTest, OnMessageReceived_InvalidObserver_Cancelled) { TEST_F(HMIMessageHandlerImplTest, SendMessageToHMI_Success) { hmi_message_handler::MessageSharedPointer message = CreateMessage(); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); MockHMIMessageAdapterImpl message_adapter(hmi_handler_); EXPECT_CALL(message_adapter, SendMessageToHMI(message)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); hmi_handler_->AddHMIMessageAdapter(&message_adapter); hmi_handler_->SendMessageToHMI(message); @@ -187,7 +187,7 @@ TEST_F(HMIMessageHandlerImplTest, SendMessageToHMI_Success) { // Wait for the message to be processed hmi_handler_->messages_to_hmi()->WaitDumpQueue(); - EXPECT_TRUE(waiter.WaitFor(1, 100)); + EXPECT_TRUE(waiter->WaitFor(1, 100)); } TEST(WebsocketSessionTest, SendMessage_UnpreparedConnection_WithoutFall) { diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 67f23956be2..54f7ab9f058 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -42,6 +42,9 @@ #include "connection_handler/connection_handler.h" #include "utils/data_accessor.h" +#include "interfaces/v4_protocol_v1_2_no_extra.h" +#include "interfaces/v4_protocol_v1_2_no_extra_schema.h" + #include "application_manager/application_manager_settings.h" #include "application_manager/hmi_interfaces.h" #include "application_manager/plugin_manager/rpc_plugin_manager.h" @@ -345,7 +348,7 @@ class ApplicationManager { /** * @brief Checks if Application is subscribed for way points - * @param Application id + * @param app_id Application id * @return true if Application is subscribed for way points * otherwise false */ @@ -353,7 +356,7 @@ class ApplicationManager { /** * @brief Checks if Application is subscribed for way points - * @param Application reference + * @param app Application reference * @return true if Application is subscribed for way points * otherwise false */ @@ -361,27 +364,45 @@ class ApplicationManager { /** * @brief Subscribe Application for way points - * @param Application id + * @param app_id Application id + * @param response_from_hmi True if a successful HMI response was received + * when subscribing */ - virtual void SubscribeAppForWayPoints(uint32_t id) = 0; + virtual void SubscribeAppForWayPoints(uint32_t app_id, + bool response_from_hmi = true) = 0; /** * @brief Subscribe Application for way points - * @param Application pointer + * @param app Application pointer + * @param response_from_hmi True if a successful HMI response was received + * when subscribing */ - virtual void SubscribeAppForWayPoints(ApplicationSharedPtr app) = 0; + virtual void SubscribeAppForWayPoints(ApplicationSharedPtr app, + bool response_from_hmi = true) = 0; /** * @brief Unsubscribe Application for way points - * @param Application id + * @param app_id Application id + * @param response_from_hmi True if a successful HMI response was received + * when unsubscribing */ - virtual void UnsubscribeAppFromWayPoints(uint32_t app_id) = 0; + virtual void UnsubscribeAppFromWayPoints(uint32_t app_id, + bool response_from_hmi = true) = 0; /** * @brief Unsubscribe Application for way points - * @param Application pointer + * @param app Application pointer + * @param response_from_hmi True if a successful HMI response was received + * when unsubscribing */ - virtual void UnsubscribeAppFromWayPoints(ApplicationSharedPtr app) = 0; + virtual void UnsubscribeAppFromWayPoints(ApplicationSharedPtr app, + bool response_from_hmi = true) = 0; + + /** + * @brief Is SDL Core subscribed to HMI waypoints + * @return true if SDL Core is subscribed to HMI waypoints, otherwise false + */ + virtual bool IsSubscribedToHMIWayPoints() const = 0; /** * @brief Is Any Application is subscribed for way points @@ -392,9 +413,12 @@ class ApplicationManager { /** * @brief Save message after OnWayPointsChangeNotification reception * @param way_points_message pointer to the smartobject + * @param app_id the app ID of the provider sending the way points update or 0 + * if the HMI is the provider */ virtual void SaveWayPointsMessage( - smart_objects::SmartObjectSPtr way_points_message) = 0; + smart_objects::SmartObjectSPtr way_points_message, + uint32_t app_id = 0) = 0; /** * @brief Get subscribed for way points @@ -599,6 +623,12 @@ class ApplicationManager { virtual bool IsStopping() const = 0; + /** + * @brief Waits for HMI readiness and blocks thread if it's not ready yet + * @return true if HMI is ready and cooperating, otherwise returns false + */ + virtual bool WaitForHmiIsReady() = 0; + virtual void RemoveAppFromTTSGlobalPropertiesList(const uint32_t app_id) = 0; /** @@ -775,6 +805,9 @@ class ApplicationManager { */ virtual HmiInterfaces& hmi_interfaces() = 0; + virtual ns_smart_device_link_rpc::V1::v4_protocol_v1_2_no_extra& + mobile_v4_protocol_so_factory() = 0; + virtual app_launch::AppLaunchCtrl& app_launch_ctrl() = 0; virtual protocol_handler::MajorProtocolVersion SupportedSDLVersion() @@ -828,8 +861,13 @@ class ApplicationManager { * @brief Callback calls when application starts/stops data streaming * @param app_id Streaming application id * @param service_type Streaming service type - * @param new_state Defines new streaming state + * @param state True if streaming started, false if streaming stopped. */ + virtual void OnAppStreaming(uint32_t app_id, + protocol_handler::ServiceType service_type, + bool state) = 0; + + DEPRECATED virtual void OnAppStreaming(uint32_t app_id, protocol_handler::ServiceType service_type, const Application::StreamingState new_state) = 0; @@ -907,6 +945,14 @@ class ApplicationManager { virtual bool IsSOStructValid( const hmi_apis::StructIdentifiers::eType struct_id, const smart_objects::SmartObject& display_capabilities) = 0; + + /** + * @brief Unsubscribe application specified in message from softbuttons. + * @param response_message - Response message received from HMI. + * @return bool - Result of unsubscribing process. + */ + virtual bool UnsubscribeAppFromSoftButtons( + const commands::MessageSharedPtr response_message) = 0; }; } // namespace application_manager diff --git a/src/components/include/application_manager/hmi_capabilities.h b/src/components/include/application_manager/hmi_capabilities.h index 56ac807d631..e7d7aa485b8 100644 --- a/src/components/include/application_manager/hmi_capabilities.h +++ b/src/components/include/application_manager/hmi_capabilities.h @@ -97,10 +97,25 @@ class HMICapabilities { /** * @brief Returns software version of the target - * @return TRUE if it supported, otherwise FALSE + * @return string representation of software version if supported, otherwise + * empty string */ virtual const std::string& ccpu_version() const = 0; + /** + * @brief Interface used to store information about hardware version of the + * target + * @param hardware_version Received system/hmi hardware version + */ + virtual void set_hardware_version(const std::string& hardware_version) = 0; + + /** + * @brief Returns hardware version of the target + * @return string representation of hardware version if supported, otherwise + * empty string + */ + virtual const std::string& hardware_version() const = 0; + /** * @brief Retrieves if mixing audio is supported by HMI * (ie recording TTS command and playing audio) 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 d8aef7cc1ab..7ada7884bf2 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -331,12 +331,26 @@ class PolicyHandlerInterface : public VehicleDataItemProvider { const std::string& wers_country_code, const std::string& language) = 0; + /** + * @brief Save hardware version from GetSystemInfo request to policy table, if + * present + * @param hardware_version Hardware version + */ + virtual void OnHardwareVersionReceived( + const std::string& hardware_version) = 0; + /** * @brief Get information about last ccpu_version from PT * @return ccpu_version from PT */ virtual std::string GetCCPUVersionFromPT() const = 0; + /** + * @brief Get information about last hardware version from PT + * @return hardware version from PT + */ + virtual std::string GetHardwareVersionFromPT() const = 0; + /** * @brief Sends GetVehicleData request in case when Vechicle info is ready. */ diff --git a/src/components/include/connection_handler/connection_handler.h b/src/components/include/connection_handler/connection_handler.h index c5995fbbb88..7cb1448a37f 100644 --- a/src/components/include/connection_handler/connection_handler.h +++ b/src/components/include/connection_handler/connection_handler.h @@ -58,6 +58,18 @@ enum CloseSessionReason { class ConnectionHandlerObserver; +/** + * @brief Helper structure to collect all required vehicle data + */ +struct ProtocolVehicleData { + std::string vehicle_make; + std::string vehicle_model; + std::string vehicle_year; + std::string vehicle_trim; + std::string vehicle_system_software_version; + std::string vehicle_system_hardware_version; +}; + // The SessionConnectionMap keeps track of the primary and secondary transports // associated with a session ID typedef struct { @@ -172,6 +184,15 @@ class ConnectionHandler { */ virtual void SendEndService(uint32_t key, uint8_t service_type) = 0; + /** + * @brief Check is heartbeat monitoring started for specified connection key + * @param connection_key pair of connection and session id + * @return returns true if heartbeat monitoring started for specified + * connection key otherwise returns false + */ + virtual bool IsSessionHeartbeatTracked( + const uint32_t connection_key) const = 0; + /** * \brief Start heartbeat for specified session * @@ -335,6 +356,14 @@ class ConnectionHandler { virtual const transport_manager::DeviceInfo& GetWebEngineDeviceInfo() const = 0; + /** + * @brief Collects all vehicle data required by a protocol layer + * @param data output structure to store received vehicle data + * @return true if data has been received successfully, otherwise returns + * false + */ + virtual bool GetProtocolVehicleData(ProtocolVehicleData& data) = 0; + /** * @brief Called when HMI cooperation is started, * creates WebSocketDevice for WebEngine diff --git a/src/components/include/connection_handler/connection_handler_observer.h b/src/components/include/connection_handler/connection_handler_observer.h index 7d6664a0097..cfbbefefd4c 100644 --- a/src/components/include/connection_handler/connection_handler_observer.h +++ b/src/components/include/connection_handler/connection_handler_observer.h @@ -177,6 +177,14 @@ class ConnectionHandlerObserver { */ virtual void OnWebEngineDeviceCreated() = 0; + /** + * @brief Collects all vehicle data required by a protocol layer + * @param data output structure to store received vehicle data + * @return true if data has been received successfully, otherwise returns + * false + */ + virtual bool GetProtocolVehicleData(ProtocolVehicleData& data) = 0; + protected: /** * \brief Destructor diff --git a/src/components/include/media_manager/media_manager.h b/src/components/include/media_manager/media_manager.h index 0729adc7d85..2d2201a949d 100644 --- a/src/components/include/media_manager/media_manager.h +++ b/src/components/include/media_manager/media_manager.h @@ -70,6 +70,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/policy/policy_external/policy/policy_manager.h b/src/components/include/policy/policy_external/policy/policy_manager.h index 9d4ad5ea575..d9844c153bd 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -432,12 +432,25 @@ class PolicyManager : public usage_statistics::StatisticsManager, const std::string& wers_country_code, const std::string& language) = 0; + /** + * @brief Set hardware version from GetSystemInfo response to policy table, if + * present + * @param hardware_version Hardware version + */ + virtual void SetHardwareVersion(const std::string& hardware_version) = 0; + /** * @brief Get information about last ccpu_version from PT * @return ccpu_version from PT */ virtual std::string GetCCPUVersionFromPT() const = 0; + /** + * @brief Get information about last hardware version from PT + * @return hardware version from PT + */ + virtual std::string GetHardwareVersionFromPT() const = 0; + /** * @brief Send OnPermissionsUpdated for choosen application * @param device_id device identifier @@ -858,6 +871,11 @@ class PolicyManager : public usage_statistics::StatisticsManager, */ virtual void ResetTimeout() = 0; + /** + * @brief Trigger a PTU once on startup if it is required + */ + virtual void TriggerPTUOnStartupIfRequired() = 0; + protected: /** * @brief Checks is PT exceeded IgnitionCycles 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 c90006928a1..b4043067ab7 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -423,12 +423,25 @@ class PolicyManager : public usage_statistics::StatisticsManager, const std::string& wers_country_code, const std::string& language) = 0; + /** + * @brief Set hardware version from GetSystemInfo response to policy table, if + * present + * @param hardware_version Hardware version + */ + virtual void SetHardwareVersion(const std::string& hardware_version) = 0; + /** * @brief Get information about last ccpu_version from PT * @return ccpu_version from PT */ virtual std::string GetCCPUVersionFromPT() const = 0; + /** + * @brief Get information about last hardware version from PT + * @return hardware version from PT + */ + virtual std::string GetHardwareVersionFromPT() const = 0; + /** * @brief Send OnPermissionsUpdated for choosen application * @param device_id device identifier diff --git a/src/components/include/protocol/bson_object_keys.h b/src/components/include/protocol/bson_object_keys.h index f81de4cc81e..830c33b3ebb 100644 --- a/src/components/include/protocol/bson_object_keys.h +++ b/src/components/include/protocol/bson_object_keys.h @@ -49,6 +49,12 @@ extern const char* tcp_ip_address; extern const char* tcp_port; extern const char* reason; extern const char* auth_token; +extern const char* vehicle_make; +extern const char* vehicle_model; +extern const char* vehicle_model_year; +extern const char* vehicle_trim; +extern const char* vehicle_system_software_version; +extern const char* vehicle_system_hardware_version; } // namespace strings diff --git a/src/components/include/protocol_handler/protocol_handler.h b/src/components/include/protocol_handler/protocol_handler.h index c7ee6709722..011592da499 100644 --- a/src/components/include/protocol_handler/protocol_handler.h +++ b/src/components/include/protocol_handler/protocol_handler.h @@ -137,16 +137,32 @@ class ProtocolHandler { * @param err_reason string with NACK reason. Only valid when * generated_session_id is 0. */ + DEPRECATED virtual void NotifySessionStarted( const SessionContext& context, std::vector& rejected_params, const std::string err_reason = std::string()) = 0; + /** + * @brief Called by connection handler to notify the context of + * OnSessionStartedCallback(). + * @param context reference to structure with started session data + * @param rejected_params list of parameters name that are rejected. + * Only valid when generated_session_id is 0. Note, even if + * generated_session_id is 0, the list may be empty. + * @param err_reason string with NACK reason. Only valid when + * generated_session_id is 0. + */ + virtual void NotifySessionStarted( + SessionContext& context, + std::vector& rejected_params, + const std::string err_reason = std::string()) = 0; + virtual bool IsRPCServiceSecure(const uint32_t connection_key) const = 0; virtual void ProcessFailedPTU() = 0; -#ifdef EXTERNAL_PROPRIETARY_MODE +#if defined(EXTERNAL_PROPRIETARY_MODE) && defined(ENABLE_SECURITY) /** * @brief ProcessFailedCertDecrypt is called to notify security manager that * certificate decryption failed in the external flow diff --git a/src/components/include/protocol_handler/session_observer.h b/src/components/include/protocol_handler/session_observer.h index 593ce8408c8..ca12f4b6ad2 100644 --- a/src/components/include/protocol_handler/session_observer.h +++ b/src/components/include/protocol_handler/session_observer.h @@ -69,6 +69,7 @@ struct SessionContext { uint32_t hash_id_; bool is_protected_; bool is_new_service_; + bool is_start_session_failed_; /** * @brief Constructor @@ -81,7 +82,8 @@ struct SessionContext { , service_type_(protocol_handler::kInvalidServiceType) , hash_id_(0) , is_protected_(false) - , is_new_service_(false) {} + , is_new_service_(false) + , is_start_session_failed_(false) {} /** * @brief Constructor @@ -111,7 +113,8 @@ struct SessionContext { , service_type_(service_type) , hash_id_(hash_id) , is_protected_(is_protected) - , is_new_service_(false) {} + , is_new_service_(false) + , is_start_session_failed_(false) {} }; /** diff --git a/src/components/include/security_manager/security_manager.h b/src/components/include/security_manager/security_manager.h index 358c4e52684..305ade2b473 100644 --- a/src/components/include/security_manager/security_manager.h +++ b/src/components/include/security_manager/security_manager.h @@ -170,7 +170,7 @@ class SecurityManager : public protocol_handler::ProtocolObserver, virtual void ProcessFailedPTU() = 0; -#ifdef EXTERNAL_PROPRIETARY_MODE +#if defined(EXTERNAL_PROPRIETARY_MODE) && defined(ENABLE_SECURITY) /** * @brief ProcessFailedCertDecrypt is called to notify listeners that * certificate decryption failed in the external flow diff --git a/src/components/include/security_manager/security_manager_settings.h b/src/components/include/security_manager/security_manager_settings.h index 0bbe0f4f96f..4e601c3e0ee 100644 --- a/src/components/include/security_manager/security_manager_settings.h +++ b/src/components/include/security_manager/security_manager_settings.h @@ -60,6 +60,7 @@ class CryptoManagerSettings { virtual size_t maximum_payload_size() const = 0; virtual const std::vector& force_protected_service() const = 0; virtual const std::vector& force_unprotected_service() const = 0; + virtual uint32_t security_level() const = 0; }; } // namespace security_manager 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 ee5d7f315a5..fd7ddeac15d 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -184,6 +184,8 @@ class MockApplicationManager : public application_manager::ApplicationManager { void(application_manager::ApplicationSharedPtr app)); MOCK_METHOD1(OnApplicationSwitched, void(application_manager::ApplicationSharedPtr app)); + MOCK_METHOD0(mobile_v4_protocol_so_factory, + ns_smart_device_link_rpc::V1::v4_protocol_v1_2_no_extra&()); MOCK_CONST_METHOD0(connection_handler, connection_handler::ConnectionHandler&()); MOCK_CONST_METHOD0(protocol_handler, protocol_handler::ProtocolHandler&()); @@ -230,6 +232,7 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_CONST_METHOD1(IsAppsQueriedFrom, bool(const connection_handler::DeviceHandle handle)); MOCK_CONST_METHOD0(IsStopping, bool()); + MOCK_METHOD0(WaitForHmiIsReady, bool()); MOCK_METHOD1(RemoveAppFromTTSGlobalPropertiesList, void(const uint32_t app_id)); MOCK_METHOD2(ResetGlobalProperties, @@ -312,11 +315,16 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD1(OnAppUnauthorized, void(const uint32_t& app_id)); MOCK_METHOD1(ActivateApplication, bool(application_manager::ApplicationSharedPtr app)); + MOCK_METHOD3(OnAppStreaming, + void(uint32_t app_id, + protocol_handler::ServiceType service_type, + bool state)); + DEPRECATED MOCK_METHOD3( OnAppStreaming, void(uint32_t app_id, protocol_handler::ServiceType service_type, - application_manager::Application::StreamingState new_state)); + const application_manager::Application::StreamingState new_state)); MOCK_CONST_METHOD6(CreateRegularState, application_manager::HmiStatePtr( application_manager::ApplicationSharedPtr app, @@ -348,19 +356,23 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD2(IsSOStructValid, bool(const hmi_apis::StructIdentifiers::eType struct_id, const smart_objects::SmartObject& display_capabilities)); + MOCK_METHOD1(UnsubscribeAppFromSoftButtons, + bool(const application_manager::commands::MessageSharedPtr + response_message)); MOCK_CONST_METHOD1(IsAppSubscribedForWayPoints, bool(uint32_t)); MOCK_CONST_METHOD1(IsAppSubscribedForWayPoints, bool(application_manager::Application& app)); - MOCK_METHOD1(SubscribeAppForWayPoints, void(uint32_t)); - MOCK_METHOD1(SubscribeAppForWayPoints, - void(application_manager::ApplicationSharedPtr)); - MOCK_METHOD1(UnsubscribeAppFromWayPoints, void(uint32_t)); - MOCK_METHOD1(UnsubscribeAppFromWayPoints, - void(application_manager::ApplicationSharedPtr)); + MOCK_METHOD2(SubscribeAppForWayPoints, void(uint32_t, bool)); + MOCK_METHOD2(SubscribeAppForWayPoints, + void(application_manager::ApplicationSharedPtr, bool)); + MOCK_METHOD2(UnsubscribeAppFromWayPoints, void(uint32_t, bool)); + MOCK_METHOD2(UnsubscribeAppFromWayPoints, + void(application_manager::ApplicationSharedPtr, bool)); + MOCK_CONST_METHOD0(IsSubscribedToHMIWayPoints, bool()); MOCK_CONST_METHOD0(IsAnyAppSubscribedForWayPoints, bool()); MOCK_CONST_METHOD0(GetAppsSubscribedForWayPoints, const std::set()); - MOCK_METHOD1(SaveWayPointsMessage, - void(std::shared_ptr)); + MOCK_METHOD2(SaveWayPointsMessage, + void(std::shared_ptr, uint32_t)); MOCK_CONST_METHOD1( WaitingApplicationByID, application_manager::ApplicationConstSharedPtr(const uint32_t)); 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 7b6da68c510..af4019ce214 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 @@ -186,7 +186,10 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { void(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& language)); + MOCK_METHOD1(OnHardwareVersionReceived, + void(const std::string& hardware_version)); MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string()); + MOCK_CONST_METHOD0(GetHardwareVersionFromPT, std::string()); MOCK_METHOD0(OnVIIsReady, void()); MOCK_METHOD1(OnVehicleDataUpdated, void(const smart_objects::SmartObject& message)); 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 bf266751d42..bdfcf55e34d 100644 --- a/src/components/include/test/connection_handler/mock_connection_handler.h +++ b/src/components/include/test/connection_handler/mock_connection_handler.h @@ -87,6 +87,8 @@ class MockConnectionHandler : public connection_handler::ConnectionHandler { uint8_t session_id, CloseSessionReason close_reason)); MOCK_METHOD2(SendEndService, void(uint32_t key, uint8_t service_type)); + MOCK_CONST_METHOD1(IsSessionHeartbeatTracked, + bool(const uint32_t connection_key)); MOCK_METHOD1(StartSessionHeartBeat, void(uint32_t connection_key)); MOCK_METHOD2(SendHeartBeat, void(ConnectionHandle connection_handle, uint8_t session_id)); @@ -137,6 +139,8 @@ class MockConnectionHandler : public connection_handler::ConnectionHandler { OnSecondaryTransportEnded, void(const transport_manager::ConnectionUID primary_connection_handle, const transport_manager::ConnectionUID secondary_connection_handle)); + MOCK_METHOD1(GetProtocolVehicleData, + bool(connection_handler::ProtocolVehicleData& data)); MOCK_METHOD0(CreateWebEngineDevice, void()); MOCK_CONST_METHOD0(GetWebEngineDeviceInfo, transport_manager::DeviceInfo&()); }; 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 61877daa236..90174017c3c 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 @@ -83,6 +83,8 @@ class MockConnectionHandlerObserver MOCK_METHOD2(SetPendingApplicationState, void(const transport_manager::ConnectionUID connection_id, const transport_manager::DeviceInfo& device_info)); + MOCK_METHOD1(GetProtocolVehicleData, + bool(connection_handler::ProtocolVehicleData& data)); }; } // namespace connection_handler_test 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 36e35352d67..364c495236d 100644 --- a/src/components/include/test/media_manager/mock_media_manager.h +++ b/src/components/include/test/media_manager/mock_media_manager.h @@ -64,6 +64,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 d93bdff7f7e..a79918cc395 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 @@ -207,7 +207,9 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { bool(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& language)); + MOCK_METHOD1(SetHardwareVersion, void(const std::string& hardware_version)); MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string()); + MOCK_CONST_METHOD0(GetHardwareVersionFromPT, std::string()); MOCK_CONST_METHOD0(IsMetaInfoPresent, bool()); MOCK_METHOD1(SetSystemLanguage, bool(const std::string& language)); MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type)); 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 0123c6c912c..22ab31307a4 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 @@ -173,6 +173,7 @@ class MockPolicyManager : public PolicyManager { void(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& language)); + MOCK_METHOD1(SetHardwareVersion, void(const std::string& hardware_version)); MOCK_METHOD1(SetPreloadedPtFlag, void(const bool is_preloaded)); MOCK_METHOD2(SendNotificationOnPermissionsUpdated, void(const std::string& device_id, @@ -269,6 +270,7 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD0(ExceededIgnitionCycles, bool()); MOCK_METHOD0(ExceededDays, bool()); MOCK_METHOD0(StartPTExchange, void()); + MOCK_METHOD0(TriggerPTUOnStartupIfRequired, void()); MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type)); MOCK_METHOD2(Increment, void(const std::string& app_id, @@ -308,6 +310,7 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD0(RetrySequenceFailed, void()); MOCK_METHOD0(ResetTimeout, void()); MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string()); + MOCK_CONST_METHOD0(GetHardwareVersionFromPT, std::string()); }; } // namespace policy_manager_test } // namespace components 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 19de301dc3e..716f66f994c 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 @@ -181,7 +181,9 @@ class MockCacheManagerInterface : public CacheManagerInterface { bool(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& language)); + MOCK_METHOD1(SetHardwareVersion, void(const std::string& hardware_version)); MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string()); + MOCK_CONST_METHOD0(GetHardwareVersionFromPT, std::string()); MOCK_CONST_METHOD0(IsMetaInfoPresent, bool()); MOCK_METHOD1(SetSystemLanguage, bool(const std::string& language)); MOCK_METHOD1(Increment, void(usage_statistics::GlobalCounterId type)); 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 4cb6455db6d..076f0423ef0 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 @@ -172,6 +172,7 @@ class MockPolicyManager : public PolicyManager { void(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& language)); + MOCK_METHOD1(SetHardwareVersion, void(const std::string& hardware_version)); MOCK_METHOD1(SetPreloadedPtFlag, void(const bool is_preloaded)); MOCK_METHOD2(SendNotificationOnPermissionsUpdated, void(const std::string& device_id, @@ -311,6 +312,7 @@ class MockPolicyManager : public PolicyManager { RequestSubType::State(const std::string& policy_app_id)); MOCK_METHOD0(ResetTimeout, void()); MOCK_CONST_METHOD0(GetCCPUVersionFromPT, std::string()); + MOCK_CONST_METHOD0(GetHardwareVersionFromPT, std::string()); }; } // namespace policy_manager_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 94a9efd9e5a..aa7c1293c36 100644 --- a/src/components/include/test/protocol_handler/mock_protocol_handler.h +++ b/src/components/include/test/protocol_handler/mock_protocol_handler.h @@ -64,6 +64,10 @@ class MockProtocolHandler : public ::protocol_handler::ProtocolHandler { MOCK_CONST_METHOD0(get_settings, const ::protocol_handler::ProtocolHandlerSettings&()); MOCK_METHOD0(get_session_observer, protocol_handler::SessionObserver&()); + MOCK_METHOD3(NotifySessionStarted, + void(::protocol_handler::SessionContext& context, + std::vector& rejected_params, + const std::string err_reason)); MOCK_METHOD3(NotifySessionStarted, void(const ::protocol_handler::SessionContext& context, std::vector& rejected_params, @@ -71,7 +75,7 @@ class MockProtocolHandler : public ::protocol_handler::ProtocolHandler { MOCK_METHOD0(NotifyOnGetSystemTimeFailed, void()); MOCK_CONST_METHOD1(IsRPCServiceSecure, bool(const uint32_t connection_key)); MOCK_METHOD0(ProcessFailedPTU, void()); -#ifdef EXTERNAL_PROPRIETARY_MODE +#if defined(EXTERNAL_PROPRIETARY_MODE) && defined(ENABLE_SECURITY) MOCK_METHOD0(ProcessFailedCertDecrypt, void()); #endif }; 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 e44d6207c1a..d6ef7d1bbd6 100644 --- a/src/components/include/test/security_manager/mock_security_manager.h +++ b/src/components/include/test/security_manager/mock_security_manager.h @@ -75,7 +75,7 @@ class MockSecurityManager : public ::security_manager::SecurityManager { MOCK_METHOD1(PostponeHandshake, void(const uint32_t)); MOCK_CONST_METHOD0(IsSystemTimeProviderReady, bool()); MOCK_METHOD0(ResetPendingSystemTimeRequests, void()); -#ifdef EXTERNAL_PROPRIETARY_MODE +#if defined(EXTERNAL_PROPRIETARY_MODE) && defined(ENABLE_SECURITY) MOCK_METHOD0(ProcessFailedCertDecrypt, void()); #endif }; diff --git a/src/components/include/test/security_manager/mock_security_manager_settings.h b/src/components/include/test/security_manager/mock_security_manager_settings.h index b1c869cd1b6..2c629734137 100644 --- a/src/components/include/test/security_manager/mock_security_manager_settings.h +++ b/src/components/include/test/security_manager/mock_security_manager_settings.h @@ -56,6 +56,7 @@ class MockCryptoManagerSettings MOCK_CONST_METHOD0(maximum_payload_size, size_t()); MOCK_CONST_METHOD0(force_protected_service, const std::vector&()); MOCK_CONST_METHOD0(force_unprotected_service, const std::vector&()); + MOCK_CONST_METHOD0(security_level, uint32_t()); }; } // namespace security_manager_test diff --git a/src/components/include/test/utils/test_async_waiter.h b/src/components/include/test/utils/test_async_waiter.h index 12d6cd04b76..6ad9ca12c53 100644 --- a/src/components/include/test/utils/test_async_waiter.h +++ b/src/components/include/test/utils/test_async_waiter.h @@ -48,17 +48,15 @@ namespace test { * * Usage example: * TEST() { - * TestAsyncWaiter waiter; + * auto waiter = TestAsyncWaiter::createInstance(); * EXPECT_CALL(mock, InterestingCall()) * .Times(n) - * .WillRepeatedly(NotifyTestAsyncWaiter(&waiter)); - * EXPECT_TRUE(waiter.WaitFor(n, 1000)); + * .WillRepeatedly(NotifyTestAsyncWaiter(waiter)); + * EXPECT_TRUE(waiter->WaitFor(n, 1000)); * } */ class TestAsyncWaiter { public: - TestAsyncWaiter() : notified_(false), count_(0), lock_(), cond_var_() {} - /** * @brief WaitFor * Waits for specified number of notifications but not longer @@ -80,6 +78,10 @@ class TestAsyncWaiter { return true; } + static std::shared_ptr createInstance() { + return std::shared_ptr(new TestAsyncWaiter()); + } + /** * @brief Notify * Notifies async waiter @@ -92,6 +94,8 @@ class TestAsyncWaiter { } private: + TestAsyncWaiter() : notified_(false), count_(0), lock_(), cond_var_() {} + bool notified_; uint32_t count_; sync_primitives::Lock lock_; diff --git a/src/components/include/utils/semantic_version.h b/src/components/include/utils/semantic_version.h index 01b04495ade..54be460bab3 100644 --- a/src/components/include/utils/semantic_version.h +++ b/src/components/include/utils/semantic_version.h @@ -43,12 +43,6 @@ struct SemanticVersion { patch_version_ = patch; } - SemanticVersion(const SemanticVersion& other) { - major_version_ = other.major_version_; - minor_version_ = other.minor_version_; - patch_version_ = other.patch_version_; - } - SemanticVersion(const std::string& versionString) : major_version_(0), minor_version_(0), patch_version_(0) { int readElements = sscanf(versionString.c_str(), diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index a9ad0792ec8..92806e73729 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -34,7 +34,7 @@ - + @@ -634,6 +634,12 @@ Optional phone number of intended location / establishment (if applicable) for SendLocation. + + Optional time to destination field for ShowConstantTBT + + + Turn text for turnList parameter of UpdateTurnList + The first line of the subtle alert text field; applies to `SubtleAlert` `alertText1` @@ -643,14 +649,17 @@ A text field in the soft button of a subtle alert; applies to `SubtleAlert` `softButtons` - - - - - Navigation text for UpdateTurnList. + + Secondary text for AddCommand + + + Tertiary text for AddCommand + + + Secondary text for AddSubMenu - - Text of notification to be displayed on screen. + + Tertiary text for AddSubMenu @@ -742,6 +751,12 @@ The image of the subtle alert; applies to `SubtleAlert` `alertIcon` + + The secondary image field for AddCommand + + + The secondary image field for AddSubMenu + @@ -832,6 +847,11 @@ + + Enumerations of all available app capability types + + + @@ -1208,6 +1228,7 @@ + @@ -1237,6 +1258,7 @@ + @@ -1326,6 +1348,7 @@ + @@ -1335,6 +1358,15 @@ + + + + + + Enumeration listing possible input character masking. + + + @@ -1741,7 +1773,6 @@ - Describes a location (origin coordinates and span) of a vehicle component. @@ -1791,7 +1822,7 @@ Describes the location of a seat. - + @@ -1806,6 +1837,21 @@ + + Describes the status of a parameter of seat. + + + + + + + Seat status array containing location and whether the seats are occupied. + + + Seat status array containing location and whether the seats are belted. + + + @@ -2226,7 +2272,7 @@ - + Temperature Unit @@ -2933,6 +2979,12 @@ The name of the sub menu/command. + + Optional secondary text to display + + + Optional tertiary text to display + @@ -3169,11 +3221,20 @@ If empty, the auto-complete list will be removed from the screen. + + Allows an app to mask entered characters on HMI + + + + Array of special characters to show in customizable keys. + If omitted, keyboard will show default special characters + + - Uses navigationText from TextFieldStruct. + Describes the `Turn` using `TextFieldName` `turnText` @@ -3334,6 +3395,35 @@ + + + + + + + + + Describes the status of a parameter of door. + + + + + + Describes the status of a parameter of trunk/hood/etc. + + + + + + + Describes the status of a parameter of roof, convertible roof, sunroof/moonroof etc. + If roof is open (AJAR), state will determine percentage of roof open. + + + + + + Must be true if the park brake is active @@ -3345,16 +3435,25 @@ The status of the ignition. See IgnitionStatus. - References signal "DrStatDrv_B_Actl". + References signal "DrStatDrv_B_Actl". Deprecated starting with RPC Spec 7.1.0. - References signal "DrStatPsngr_B_Actl". + References signal "DrStatPsngr_B_Actl". Deprecated starting with RPC Spec 7.1.0. - References signal "DrStatRl_B_Actl". + References signal "DrStatRl_B_Actl". Deprecated starting with RPC Spec 7.1.0. - References signal "DrStatRr_B_Actl". + References signal "DrStatRr_B_Actl". Deprecated starting with RPC Spec 7.1.0. + + + Provides status for doors if Ajar/Closed/Locked + + + Provides status for trunk/hood/etc. if Ajar/Closed/Locked + + + Provides status for roof/convertible roof/sunroof/moonroof etc., if Closed/Ajar/Removed etc. @@ -3606,6 +3705,23 @@ The scaling factor the app should use to change the size of the projecting view. + + The preferred frame rate per second of the head unit. The mobile application / app library may take other factors into account that constrain the frame rate lower than this value, but it should not perform streaming at a higher frame rate than this value. + + + + + + + + + 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. + + + + Describes supported capabilities for video streaming + @@ -3623,6 +3739,25 @@ + + + Describes the capabilities of a single keyboard layout. + + + + Number of keys available for special characters, App can customize as per their needs. + + + + + + Availability of capability to mask input characters using keyboard. True: Available, False: Not Available + + + Capabilities of supported keyboard layouts by HMI. + + + @@ -3657,6 +3792,9 @@ Contains the head unit's capabilities for dynamic updating features declaring if the module will send dynamic update RPCs. + + See KeyboardCapabilities + @@ -3700,7 +3838,7 @@ Describes capabilities when the driver is distracted - + @@ -4300,6 +4438,18 @@ + + + The external temperature in degrees celsius + + + Internal ambient cabin temperature in degrees celsius + + + Current atmospheric pressure in mBar + + + Gear position selected by the user i.e. Park, Drive, Reverse @@ -4312,6 +4462,23 @@ + + + + + + + + The seek next / skip previous subscription buttons' content + + + + + If the type is TIME, this number of seconds may be present alongside the skip indicator. + It will indicate the number of seconds that the currently playing media will skip forward or backward. + + + @@ -4399,27 +4566,27 @@ - - - - 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. - - + + + + 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. @@ -4789,6 +4956,9 @@ Country code from the Ford system WERS (i.e.WAEGB). + + The hardware version of the system + Issued by system to SDL to notify that some system param has changed. Currently applied for Sync Language. @@ -4870,9 +5040,18 @@ The new application properties + + + A notification to inform HMI that a specific app capability has changed. + + The app capability that has been updated + + + + - + Method is invoked at system startup. Response provides information about presence of VR module and its readiness to cooperate with SDL. @@ -5152,7 +5331,7 @@ - + Request from SDL to show an alert message on the display. @@ -5409,6 +5588,9 @@ Image to be displayed for representing the command. See Image. If omitted, no (or the default if applicable) icon should be displayed. + + Optional secondary image struct for menu cell + ID of application that concerns this RPC. @@ -5441,6 +5623,9 @@ The image field for AddSubMenu + + Optional secondary image struct for menu cell + ID of application that requested this RPC. @@ -5553,6 +5738,19 @@ Indicates that a button press of the Play/Pause button would play, pause or Stop the current playback. + + Used to control the forward seek button to either skip forward a set amount of time or to the next track. + + + Used to control the backward seek button to either skip back a set amount of time or to the previous track. + + + + The value of this parameter is the amount that the media clock timer will advance per 1.0 seconds of real time. + Values less than 1.0 will therefore advance the timer slower than real-time, while values greater than 1.0 will advance the timer faster than real-time. + e.g. If this parameter is set to `0.5`, the timer will advance one second per two seconds real-time, or at 50% speed. If this parameter is set to `2.0`, the timer will advance two seconds per one second real-time, or at 200% speed. + + ID of application that requested this RPC. @@ -5890,7 +6088,7 @@ - + Method is invoked at system startup. Response must provide the information about presence of UI Navigation module and its readiness to cooperate with SDL. @@ -5954,12 +6152,10 @@ - Fraction of distance till next maneuver (from previous maneuver). - May be used to calculate progress bar. + Distance (in meters) until next maneuver. May be used to calculate progress bar. - Fraction of distance till next maneuver (starting from when AlertManeuver is triggered). - May be used to calculate progress bar. + Distance (in meters) from previous maneuver to next maneuver. May be used to calculate progress bar. If and when a maneuver has completed while an AlertManeuver is active, SDL will send this value set to TRUE in order to clear the AlertManeuver overlay. @@ -6116,7 +6312,7 @@ - + Method is invoked at system startup. Response should provide information about presence of any of vehicle information modules (ECU, GPS, etc) and their readiness to cooperate with SDL. @@ -6230,6 +6426,9 @@ The external temperature in degrees celsius + + See ClimateData + See TurnSignal @@ -6290,6 +6489,9 @@ To indicate whether driver hands are off the steering wheel + + See SeatOccupancy + @@ -6338,6 +6540,9 @@ The external temperature in degrees celsius. + + See ClimateData + See TurnSignal @@ -6398,6 +6603,9 @@ To indicate whether driver hands are off the steering wheel + + See SeatOccupancy + @@ -6449,6 +6657,9 @@ The external temperature in degrees celsius. + + See ClimateData + See TurnSignal @@ -6509,6 +6720,9 @@ To indicate whether driver hands are off the steering wheel + + See SeatOccupancy + @@ -6557,6 +6771,9 @@ The external temperature in degrees celsius + + See ClimateData + See TurnSignal @@ -6617,6 +6834,9 @@ To indicate whether driver hands are off the steering wheel + + See SeatOccupancy + @@ -6666,6 +6886,9 @@ The external temperature in degrees celsius + + See ClimateData + See TurnSignal @@ -6729,6 +6952,9 @@ To indicate whether driver hands are off the steering wheel + + See SeatOccupancy + @@ -6777,6 +7003,9 @@ The external temperature in degrees celsius + + See ClimateData + See TurnSignal @@ -6840,6 +7069,9 @@ To indicate whether driver hands are off the steering wheel + + See SeatOccupancy + @@ -6889,6 +7121,9 @@ The external temperature in degrees celsius + + See ClimateData + See TurnSignal @@ -6952,6 +7187,9 @@ To indicate whether driver hands are off the steering wheel + + See SeatOccupancy + @@ -6975,7 +7213,7 @@ - + @@ -7156,7 +7394,7 @@ - + Method is invoked at system startup. Response should provide information about presence of any of remote controllable module and its readiness to cooperate with SDL. @@ -7279,7 +7517,7 @@ - + Interface used for interacting with app services as a producer or consumer 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 8d60cd0e54e..3e24212ed52 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,6 +33,7 @@ #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 "interfaces/MOBILE_API.h" @@ -79,6 +80,7 @@ class MediaManagerImpl : public MediaManager, protocol_handler::ServiceType service_type); virtual void StopStreaming(int32_t application_key, protocol_handler::ServiceType service_type); + virtual void SetProtocolHandler( protocol_handler::ProtocolHandler* protocol_handler); virtual void OnMessageReceived( @@ -89,6 +91,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); @@ -114,6 +118,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/src/media_manager_impl.cc b/src/components/media_manager/src/media_manager_impl.cc index 6f0a67b0c91..4fc8b38d87d 100644 --- a/src/components/media_manager/src/media_manager_impl.cc +++ b/src/components/media_manager/src/media_manager_impl.cc @@ -35,6 +35,8 @@ #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 "interfaces/MOBILE_API.h" #include "media_manager/audio/from_mic_recorder_listener.h" #include "media_manager/streamer_listener.h" #include "protocol_handler/protocol_handler.h" @@ -64,6 +66,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 +165,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) { @@ -276,6 +298,8 @@ void MediaManagerImpl::StopStreaming( int32_t application_key, protocol_handler::ServiceType service_type) { SDL_LOG_AUTO_TRACE(); + stream_data_size_ = 0ull; + if (streamer_[service_type]) { streamer_[service_type]->StopActivity(application_key); } @@ -313,7 +337,24 @@ void MediaManagerImpl::OnMessageReceived( ApplicationSharedPtr app = application_manager_.application(streaming_app_id); if (app) { - app->WakeUpStreaming(service_type); + if (ServiceType::kAudio == service_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); } } @@ -326,36 +367,16 @@ 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) { - size_t audio_queue_size = audio_stream->GetMsgQueueSize(); - SDL_LOG_DEBUG("# Messages in audio queue = " << audio_queue_size); - if (audio_queue_size > 0) { - app->WakeUpStreaming(protocol_handler::ServiceType::kAudio); - } - } - - if (video_stream.use_count() != 0) { - size_t video_queue_size = video_stream->GetMsgQueueSize(); - SDL_LOG_DEBUG("# 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/streamer_adapter.cc b/src/components/media_manager/src/streamer_adapter.cc index 8dedd56ea5b..808b9715afc 100644 --- a/src/components/media_manager/src/streamer_adapter.cc +++ b/src/components/media_manager/src/streamer_adapter.cc @@ -59,6 +59,7 @@ void StreamerAdapter::StartActivity(int32_t application_key) { << " has been already started"); return; } + messages_.Reset(); DCHECK(thread_); const size_t kStackSize = 16384; @@ -86,7 +87,6 @@ void StreamerAdapter::StopActivity(int32_t application_key) { DCHECK(streamer_); streamer_->exitThreadMain(); - messages_.Reset(); for (std::set::iterator it = media_listeners_.begin(); media_listeners_.end() != it; 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 a64faabe913..ab0a9cf4947 100644 --- a/src/components/media_manager/test/media_manager_impl_test.cc +++ b/src/components/media_manager/test/media_manager_impl_test.cc @@ -35,6 +35,7 @@ #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 "gmock/gmock.h" @@ -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, _)); MockMediaAdapterImplPtr mock_media_streamer = std::make_shared(); media_manager_impl_->set_mock_streamer(service_type, mock_media_streamer); @@ -206,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, @@ -410,17 +416,11 @@ TEST_F(MediaManagerImplTest, TEST_F(MediaManagerImplTest, CheckFramesProcessed_WithCorrectFramesNumber_SUCCESS) { - ON_CALL(mock_media_manager_settings_, video_server_type()) - .WillByDefault(ReturnRef(kDefaultValue)); - ON_CALL(mock_media_manager_settings_, audio_server_type()) - .WillByDefault(ReturnRef(kDefaultValue)); protocol_handler_test::MockProtocolHandler mock_protocol_handler; media_manager_impl_->SetProtocolHandler(&mock_protocol_handler); 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/include/policy/cache_manager.h b/src/components/policy/policy_external/include/policy/cache_manager.h index 12fe8f10cd0..8384f56f776 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -597,13 +597,11 @@ class CacheManager : public CacheManagerInterface { */ void SetPreloadedPtFlag(const bool is_preloaded) OVERRIDE; - /** - * @brief Records information about head unit system to PT - * @return bool Success of operation - */ bool SetMetaInfo(const std::string& ccpu_version, const std::string& wers_country_code, - const std::string& language); + const std::string& language) OVERRIDE; + + void SetHardwareVersion(const std::string& hardware_version) OVERRIDE; /** * @brief Get information about last ccpu_version from PT @@ -611,6 +609,8 @@ class CacheManager : public CacheManagerInterface { */ std::string GetCCPUVersionFromPT() const; + std::string GetHardwareVersionFromPT() const OVERRIDE; + /** * @brief Checks, if specific head unit is present in PT * @return boot Suceess, if present, otherwise - false 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 8ed46e0c726..f33dabd0258 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 @@ -645,19 +645,31 @@ class CacheManagerInterface { virtual void SetPreloadedPtFlag(const bool is_preloaded) = 0; /** - * @brief Records information about head unit system to PT + * @brief Records mandatory information about head unit system to PT * @return bool Success of operation */ virtual bool SetMetaInfo(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& language) = 0; + /** + * @brief Records information about hardware version to PT + * @param hardware_version Hardware version + */ + virtual void SetHardwareVersion(const std::string& hardware_version) = 0; + /** * @brief Get information about last ccpu_version from PT * @return ccpu_version from PT */ virtual std::string GetCCPUVersionFromPT() const = 0; + /** + * @brief Get information about last hardware version from PT + * @return hardware version from PT + */ + virtual std::string GetHardwareVersionFromPT() const = 0; + /** * @brief Checks, if specific head unit is present in PT * @return boot Suceess, if present, otherwise - false 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 27ce30bb3da..813af17b3f6 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 @@ -435,10 +435,14 @@ class PolicyManagerImpl : public PolicyManager { const std::string& wers_country_code, const std::string& language) OVERRIDE; + void SetHardwareVersion(const std::string& hardware_version) OVERRIDE; + void SetPreloadedPtFlag(const bool is_preloaded) OVERRIDE; std::string GetCCPUVersionFromPT() const OVERRIDE; + std::string GetHardwareVersionFromPT() const OVERRIDE; + /** * @brief Get number of notification by priority * @param priority Specified priority @@ -1052,6 +1056,11 @@ class PolicyManagerImpl : public PolicyManager { */ void StartPTExchange() OVERRIDE; + /** + * @brief Trigger a PTU once on startup if it is required + */ + void TriggerPTUOnStartupIfRequired() OVERRIDE; + /** * @brief Checks is PT exceeded days * @return true if exceeded 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 6b2f05d3365..25439f835bb 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 @@ -490,6 +490,7 @@ struct ModuleMeta : CompositeType { Optional > ccpu_version; Optional > language; Optional > wers_country_code; + Optional > hardware_version; Optional > pt_exchanged_at_odometer_x; Optional > pt_exchanged_x_days_after_epoch; Optional > ignition_cycles_since_last_exchange; 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 64eab518702..a3b91abbc5e 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 @@ -25,6 +25,7 @@ + @@ -60,6 +61,7 @@ + @@ -221,6 +223,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 7e8abd59892..ff3a89d0840 100644 --- a/src/components/policy/policy_external/include/policy/policy_types.h +++ b/src/components/policy/policy_external/include/policy/policy_types.h @@ -278,6 +278,7 @@ struct AppPermissions { , appRevoked(false) , appPermissionsConsentNeeded(false) , appUnauthorized(false) + , isSDLAllowed(false) , requestTypeChanged(false) , requestSubTypeChanged(false) {} 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 f03947268a9..867033bc205 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 @@ -198,13 +198,19 @@ class PTExtRepresentation : public virtual PTRepresentation { const std::string& language) = 0; /** - * @brief Records information about head unit system to PT + * @brief Records mandatory information about head unit system to PT * @return bool Success of operation */ virtual bool SetMetaInfo(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& language) = 0; + /** + * @brief Records information about hardware version to PT + * @param hardware_version Hardware version + */ + virtual void SetHardwareVersion(const std::string& hardware_version) = 0; + /** * @brief Checks, if specific head unit is present in PT * @return boot Suceess, if present, otherwise - false diff --git a/src/components/policy/policy_external/include/policy/sql_pt_ext_queries.h b/src/components/policy/policy_external/include/policy/sql_pt_ext_queries.h index b8f85ec7b19..abb18d51e4d 100644 --- a/src/components/policy/policy_external/include/policy/sql_pt_ext_queries.h +++ b/src/components/policy/policy_external/include/policy/sql_pt_ext_queries.h @@ -65,6 +65,7 @@ extern const std::string kInsertExternalConsentStatusGroups; extern const std::string kCountUnconsentedGroups; extern const std::string kSelectModuleMeta; extern const std::string kUpdateMetaParams; +extern const std::string kUpdateMetaHardwareVersion; extern const std::string kUpdateModuleMetaVinParam; extern const std::string kSaveModuleMeta; extern const std::string kSelectMetaParams; 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 889ede9d20f..de2d0c15360 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 @@ -94,7 +94,9 @@ class SQLPTExtRepresentation : public SQLPTRepresentation, bool SetMetaInfo(const std::string& ccpu_version, const std::string& wers_country_code, - const std::string& language); + const std::string& language) OVERRIDE; + + void SetHardwareVersion(const std::string& hardware_version) OVERRIDE; bool IsMetaInfoPresent(); diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index 81a5518cb8e..07f2df19918 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -348,17 +348,20 @@ bool CacheManager::CanAppKeepContext(const std::string& app_id) const { bool result = false; if (kDeviceId == app_id) { result = pt_->policy_table.app_policies_section.device.keep_context; - } else if (IsApplicationRepresented(app_id)) { + } else if (IsApplicationRepresented(app_id) && + !IsApplicationRevoked(app_id)) { result = pt_->policy_table.app_policies_section.apps[app_id].keep_context; } return result; } uint32_t CacheManager::HeartBeatTimeout(const std::string& app_id) const { + SDL_LOG_AUTO_TRACE(); CACHE_MANAGER_CHECK(0); sync_primitives::AutoLock auto_lock(cache_lock_); uint32_t result = 0; if (!IsApplicationRepresented(app_id)) { + SDL_LOG_WARN("Application " << app_id << " is not represented"); return result; } @@ -368,6 +371,7 @@ uint32_t CacheManager::HeartBeatTimeout(const std::string& app_id) const { result = *(app.heart_beat_timeout_ms); } + SDL_LOG_DEBUG("HB timer for app " << app_id << " is " << result); return result; } @@ -407,7 +411,8 @@ bool CacheManager::CanAppStealFocus(const std::string& app_id) const { bool result = false; if (kDeviceId == app_id) { result = pt_->policy_table.app_policies_section.device.steal_focus; - } else if (IsApplicationRepresented(app_id)) { + } else if (IsApplicationRepresented(app_id) && + !IsApplicationRevoked(app_id)) { result = pt_->policy_table.app_policies_section.apps[app_id].steal_focus; } return result; @@ -422,7 +427,8 @@ bool CacheManager::GetDefaultHMI(const std::string& app_id, if (kDeviceId == app_id) { default_hmi = EnumToJsonString( pt_->policy_table.app_policies_section.device.default_hmi); - } else if (IsApplicationRepresented(app_id)) { + } else if (IsApplicationRepresented(app_id) && + !IsApplicationRevoked(app_id)) { default_hmi = EnumToJsonString( pt_->policy_table.app_policies_section.apps[app_id].default_hmi); } @@ -671,6 +677,7 @@ void CacheManager::ProcessUpdate( const policy_table::ApplicationPolicies::const_iterator initial_policy_iter) { using namespace policy; + using rpc::policy_table_interface_base::ApplicationParams; using rpc::policy_table_interface_base::RequestTypes; const RequestTypes& new_request_types = *(initial_policy_iter->second.RequestType); @@ -678,6 +685,14 @@ void CacheManager::ProcessUpdate( const std::string& app_id = initial_policy_iter->first; bool update_request_types = true; + ApplicationParams& params = + pt_->policy_table.app_policies_section.apps[app_id]; + if (kPreDataConsentId == app_id) { + *(params.heart_beat_timeout_ms) = + *(initial_policy_iter->second.heart_beat_timeout_ms); + SDL_LOG_INFO("heart_beat_timeout_ms in predata = " + << *(params.heart_beat_timeout_ms)); + } if (app_id == kDefaultId || app_id == kPreDataConsentId) { if (new_request_types.is_omitted()) { SDL_LOG_INFO("Application " << app_id @@ -1820,7 +1835,8 @@ bool CacheManager::GetPriority(const std::string& policy_app_id, policy_table::ApplicationPolicies::const_iterator policy_iter = policies.find(policy_app_id); - const bool app_id_exists = policies.end() != policy_iter; + const bool app_id_exists = + policies.end() != policy_iter && !IsApplicationRevoked(policy_app_id); if (app_id_exists) { priority = EnumToJsonString((*policy_iter).second.priority); } @@ -2031,7 +2047,8 @@ void CacheManager::PersistData() { *(*copy_pt.policy_table.module_meta).wers_country_code, *(*copy_pt.policy_table.module_meta).language); ex_backup_->SetVINValue(*(*copy_pt.policy_table.module_meta).vin); - + ex_backup_->SetHardwareVersion( + *(*copy_pt.policy_table.module_meta).hardware_version); // Save unpaired flag for devices policy_table::DeviceData::const_iterator it_device = copy_pt.policy_table.device_data->begin(); @@ -2284,13 +2301,35 @@ bool CacheManager::SetMetaInfo(const std::string& ccpu_version, return true; } +void CacheManager::SetHardwareVersion(const std::string& hardware_version) { + SDL_LOG_AUTO_TRACE(); + CACHE_MANAGER_CHECK_VOID(); + sync_primitives::AutoLock auto_lock(cache_lock_); + + *pt_->policy_table.module_meta->hardware_version = hardware_version; + Backup(); +} + std::string CacheManager::GetCCPUVersionFromPT() const { SDL_LOG_AUTO_TRACE(); + CACHE_MANAGER_CHECK(std::string("")); + sync_primitives::AutoLock auto_lock(cache_lock_); + rpc::Optional& module_meta = pt_->policy_table.module_meta; return *(module_meta->ccpu_version); } +std::string CacheManager::GetHardwareVersionFromPT() const { + SDL_LOG_AUTO_TRACE(); + CACHE_MANAGER_CHECK(std::string("")); + sync_primitives::AutoLock auto_lock(cache_lock_); + + rpc::Optional& module_meta = + pt_->policy_table.module_meta; + return *(module_meta->hardware_version); +} + bool CacheManager::IsMetaInfoPresent() const { CACHE_MANAGER_CHECK(false); sync_primitives::AutoLock lock(cache_lock_); @@ -2524,6 +2563,10 @@ bool policy::CacheManager::SetIsPredata(const std::string& app_id) { if (IsApplicationRepresented(app_id)) { pt_->policy_table.app_policies_section.apps[app_id].set_to_string( kPreDataConsentId); + + pt_->policy_table.app_policies_section.apps[app_id].heart_beat_timeout_ms = + pt_->policy_table.app_policies_section.apps[kPreDataConsentId] + .heart_beat_timeout_ms; } return true; 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 9bcea70803a..d6aa007ac10 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -762,6 +762,13 @@ void PolicyManagerImpl::StartPTExchange() { } } +void PolicyManagerImpl::TriggerPTUOnStartupIfRequired() { + SDL_LOG_AUTO_TRACE(); + if (ignition_check) { + StartPTExchange(); + } +} + void PolicyManagerImpl::OnAppsSearchStarted() { SDL_LOG_AUTO_TRACE(); update_status_manager_.OnAppsSearchStarted(); @@ -1617,11 +1624,22 @@ void PolicyManagerImpl::SetSystemInfo(const std::string& ccpu_version, cache_->SetMetaInfo(ccpu_version, wers_country_code, language); } +void PolicyManagerImpl::SetHardwareVersion( + const std::string& hardware_version) { + SDL_LOG_AUTO_TRACE(); + cache_->SetHardwareVersion(hardware_version); +} + std::string PolicyManagerImpl::GetCCPUVersionFromPT() const { SDL_LOG_AUTO_TRACE(); return cache_->GetCCPUVersionFromPT(); } +std::string PolicyManagerImpl::GetHardwareVersionFromPT() const { + SDL_LOG_AUTO_TRACE(); + return cache_->GetHardwareVersionFromPT(); +} + uint32_t PolicyManagerImpl::GetNotificationsNumber(const std::string& priority, const bool is_subtle) const { SDL_LOG_AUTO_TRACE(); 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 243cf980660..47c4202de00 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -1357,8 +1357,7 @@ ConsumerFriendlyMessages::ConsumerFriendlyMessages(const Json::Value* value__) Json::Value ConsumerFriendlyMessages::ToJsonValue() const { Json::Value result__(Json::objectValue); impl::WriteJsonField("version", version, &result__); - // According to requirements, it is not necessary to provide this to PTS - // impl::WriteJsonField("messages", messages, &result__); + impl::WriteJsonField("messages", messages, &result__); return result__; } @@ -1425,6 +1424,7 @@ ModuleMeta::ModuleMeta(const Json::Value* value__) , ccpu_version(impl::ValueMember(value__, "ccpu_version")) , language(impl::ValueMember(value__, "language")) , wers_country_code(impl::ValueMember(value__, "wers_country_code")) + , hardware_version(impl::ValueMember(value__, "hardware_version")) , pt_exchanged_at_odometer_x( impl::ValueMember(value__, "pt_exchanged_at_odometer_x")) , pt_exchanged_x_days_after_epoch( @@ -1438,6 +1438,7 @@ Json::Value ModuleMeta::ToJsonValue() const { impl::WriteJsonField("ccpu_version", ccpu_version, &result__); impl::WriteJsonField("language", language, &result__); impl::WriteJsonField("wers_country_code", wers_country_code, &result__); + impl::WriteJsonField("hardware_version", hardware_version, &result__); impl::WriteJsonField( "pt_exchanged_at_odometer_x", pt_exchanged_at_odometer_x, &result__); impl::WriteJsonField("pt_exchanged_x_days_after_epoch", @@ -1463,6 +1464,11 @@ bool ModuleMeta::is_valid() const { if (!wers_country_code.is_valid()) { return false; } + + if (!hardware_version.is_valid()) { + return false; + } + if (!pt_exchanged_at_odometer_x.is_valid()) { return false; } @@ -1493,6 +1499,11 @@ bool ModuleMeta::struct_empty() const { if (wers_country_code.is_initialized()) { return false; } + + if (hardware_version.is_initialized()) { + return false; + } + if (pt_exchanged_at_odometer_x.is_initialized()) { return false; } @@ -1507,6 +1518,7 @@ bool ModuleMeta::struct_empty() const { if (vin.is_initialized()) { return false; } + return true; } @@ -1524,6 +1536,10 @@ void ModuleMeta::ReportErrors(rpc::ValidationReport* report__) const { wers_country_code.ReportErrors( &report__->ReportSubobject("wers_country_code")); } + if (!hardware_version.is_valid()) { + hardware_version.ReportErrors( + &report__->ReportSubobject("hardware_version")); + } if (!pt_exchanged_at_odometer_x.is_valid()) { pt_exchanged_at_odometer_x.ReportErrors( &report__->ReportSubobject("pt_exchanged_at_odometer_x")); @@ -1552,6 +1568,7 @@ void ModuleMeta::SetPolicyTableType(PolicyTableType pt_type) { ccpu_version.SetPolicyTableType(pt_type); language.SetPolicyTableType(pt_type); wers_country_code.SetPolicyTableType(pt_type); + hardware_version.SetPolicyTableType(pt_type); pt_exchanged_at_odometer_x.SetPolicyTableType(pt_type); pt_exchanged_x_days_after_epoch.SetPolicyTableType(pt_type); ignition_cycles_since_last_exchange.SetPolicyTableType(pt_type); 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 ea323908c03..26d2124d072 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 @@ -170,18 +170,27 @@ const std::string kCountUnconsentedGroups = " WHERE (`a`.`functional_group_id` = `f`.`id`" " AND`f`.`user_consent_prompt` IS NULL))"; -const std::string kSelectModuleMeta = "SELECT* FROM `module_meta`"; +const std::string kSelectModuleMeta = + "SELECT `ccpu_version`, `language`, " + "`wers_country_code`, `hardware_version`, `pt_exchanged_at_odometer_x`, " + "`pt_exchanged_x_days_after_epoch`, " + "`ignition_cycles_since_last_exchange`, `vin` " + "FROM `module_meta`"; const std::string kUpdateMetaParams = "UPDATE `module_meta` SET " - "`ccpu_version` = ?, `wers_country_code` = ?, `language` = ? "; + "`ccpu_version` = ?, `wers_country_code` = ?, `language` = ?"; + +const std::string kUpdateMetaHardwareVersion = + "UPDATE `module_meta` SET `hardware_version` = ? "; const std::string kUpdateModuleMetaVinParam = "UPDATE `module_meta` SET `vin` = ? "; const std::string kSaveModuleMeta = "UPDATE `module_meta` SET `ccpu_version` = ?, `language` = ?," - "`wers_country_code` = ?, `pt_exchanged_at_odometer_x` = ?," + "`wers_country_code` = ?, `hardware_version` = ?, " + "`pt_exchanged_at_odometer_x` = ?," "`pt_exchanged_x_days_after_epoch` = ?," "`ignition_cycles_since_last_exchange` = ?, `vin` = ?"; 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 7147e0949d0..fc355518087 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 @@ -600,6 +600,22 @@ bool SQLPTExtRepresentation::SetMetaInfo(const std::string& ccpu_version, return true; } +void SQLPTExtRepresentation::SetHardwareVersion( + const std::string& hardware_version) { + SDL_LOG_AUTO_TRACE(); + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt_ext::kUpdateMetaHardwareVersion)) { + SDL_LOG_WARN("Incorrect statement for insert to module meta."); + return; + } + + query.Bind(0, hardware_version); + + if (!query.Exec()) { + SDL_LOG_WARN("Incorrect insert to module meta."); + } +} + bool SQLPTExtRepresentation::IsMetaInfoPresent() { SDL_LOG_AUTO_TRACE(); utils::dbms::SQLQuery query(db()); @@ -1320,10 +1336,11 @@ void SQLPTExtRepresentation::GatherModuleMeta( *meta->ccpu_version = query.GetString(0); *meta->language = query.GetString(1); *meta->wers_country_code = query.GetString(2); - *meta->pt_exchanged_at_odometer_x = query.GetInteger(3); - *meta->pt_exchanged_x_days_after_epoch = query.GetInteger(4); - *meta->ignition_cycles_since_last_exchange = query.GetInteger(5); - *meta->vin = query.GetString(6); + *meta->hardware_version = query.GetString(3); + *meta->pt_exchanged_at_odometer_x = query.GetInteger(4); + *meta->pt_exchanged_x_days_after_epoch = query.GetInteger(5); + *meta->ignition_cycles_since_last_exchange = query.GetInteger(6); + *meta->vin = query.GetString(7); } } @@ -1652,10 +1669,11 @@ bool SQLPTExtRepresentation::SaveModuleMeta( query.Bind(0, *(meta.ccpu_version)); query.Bind(1, *(meta.language)); query.Bind(2, *(meta.wers_country_code)); - query.Bind(3, odometer); - query.Bind(4, *(meta.pt_exchanged_x_days_after_epoch)); - query.Bind(5, *(meta.ignition_cycles_since_last_exchange)); - query.Bind(6, *(meta.vin)); + query.Bind(3, *(meta.hardware_version)); + query.Bind(4, odometer); + query.Bind(5, *(meta.pt_exchanged_x_days_after_epoch)); + query.Bind(6, *(meta.ignition_cycles_since_last_exchange)); + query.Bind(7, *(meta.vin)); if (!query.Exec()) { SDL_LOG_WARN("Incorrect update for module_meta."); 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 9e69d2cef8d..519e51dde59 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -59,6 +59,7 @@ const std::string kCreateSchema = " `ccpu_version` VARCHAR(45), " " `language` VARCHAR(45), " " `wers_country_code` VARCHAR(45), " + " `hardware_version` VARCHAR(45), " " `pt_exchanged_at_odometer_x` INTEGER NOT NULL DEFAULT 0, " " `pt_exchanged_x_days_after_epoch` INTEGER NOT NULL DEFAULT 0, " " `ignition_cycles_since_last_exchange` INTEGER NOT NULL DEFAULT 0, " diff --git a/src/components/policy/policy_external/test/CMakeLists.txt b/src/components/policy/policy_external/test/CMakeLists.txt index 8f1b8b2539b..7a28b2d3c28 100644 --- a/src/components/policy/policy_external/test/CMakeLists.txt +++ b/src/components/policy/policy_external/test/CMakeLists.txt @@ -52,6 +52,8 @@ file (GLOB POLICY_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/policy_manager_impl_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/sql_pt_ext_representation_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/sql_pt_representation_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/sql_pt_representation_storage_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/sql_pt_ext_representation_storage_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/update_status_manager_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/shared_library_test.cc) diff --git a/src/components/policy/policy_external/test/cache_manager_test.cc b/src/components/policy/policy_external/test/cache_manager_test.cc index 746d0c72215..9819811803c 100644 --- a/src/components/policy/policy_external/test/cache_manager_test.cc +++ b/src/components/policy/policy_external/test/cache_manager_test.cc @@ -2169,6 +2169,18 @@ TEST_F(CacheManagerTest, RemoveAppConsentForGroup_GroupIsRemoved) { EXPECT_FALSE(unconsented_groups_after_removal.empty()); } +TEST_F(CacheManagerTest, GetHardwareVersion_ValueWasSetBefore_ReturnValue) { + std::string hardware_version = "1.1.1.1"; + cache_manager_->SetHardwareVersion(hardware_version); + EXPECT_EQ(hardware_version, cache_manager_->GetHardwareVersionFromPT()); +} + +TEST_F(CacheManagerTest, + GetHardwareVersion_ValueNotSettedBefore_ReturnEmptyString) { + std::string empty_string = ""; + EXPECT_EQ(empty_string, cache_manager_->GetHardwareVersionFromPT()); +} + } // namespace policy_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 b307270b100..f43fedcfab7 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 @@ -105,6 +105,7 @@ class MockPTExtRepresentation : public MockPTRepresentation, bool(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& vin)); + MOCK_METHOD1(SetHardwareVersion, void(const std::string& hardware_version)); MOCK_METHOD0(IsMetaInfoPresent, bool()); MOCK_METHOD1(SetSystemLanguage, bool(const std::string& language)); MOCK_METHOD0(GetKmFromSuccessfulExchange, int()); 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 4d39e699b52..95fc783b2d4 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 @@ -66,6 +66,7 @@ const int kServiceTypeInt = 0; const std::string kDeviceNumber = "XXX123456789ZZZ"; const std::string kAppStorageFolder = "app_storage_folder"; const std::string kValidAppId = "1234"; +const std::vector kDevices{kDeviceNumber}; } // namespace class PolicyManagerImplTest : public ::testing::Test { @@ -88,6 +89,7 @@ class PolicyManagerImplTest : public ::testing::Test { ON_CALL(policy_settings_, app_storage_folder()) .WillByDefault(ReturnRef(kAppStorageFolder)); + ON_CALL(listener_, GetDevicesIds(_)).WillByDefault(Return(kDevices)); } ::testing::AssertionResult IsValid(const policy_table::Table& table) { diff --git a/src/components/policy/policy_external/test/sql_pt_ext_representation_storage_test.cc b/src/components/policy/policy_external/test/sql_pt_ext_representation_storage_test.cc index 1ceb5ea1efd..09df17beb2f 100644 --- a/src/components/policy/policy_external/test/sql_pt_ext_representation_storage_test.cc +++ b/src/components/policy/policy_external/test/sql_pt_ext_representation_storage_test.cc @@ -38,8 +38,6 @@ #include "policy/mock_policy_settings.h" #include "sqlite_wrapper/sql_query.h" #include "utils/file_system.h" -#include "utils/make_shared.h" -#include "utils/shared_ptr.h" using namespace ::policy; 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 97613550f26..58f526d7d37 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 @@ -38,12 +38,14 @@ #include #include #include "gtest/gtest.h" +#include "json/reader.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" +#include "utils/jsoncpp_reader_wrapper.h" using namespace ::policy; namespace policy_table = rpc::policy_table_interface_base; @@ -57,6 +59,44 @@ namespace test { namespace components { namespace policy_test { +namespace { +const std::string kSdlPreloadedPtJson = "json/sdl_preloaded_pt.json"; +const std::string kHardwareVersion = "1.1.1.0"; +const std::string kSoftwareVersion = "4.1.3.B_EB355B"; +const std::string kWersCountryCode = "WAEGB"; +const std::string kLanguage = "EN-US"; +const std::string kFunctionalGroupWithParams = "Location-1"; +const std::string kUserConsentForGroupWithParams = "Location"; +const std::string kRpcForGroupWithParams = "GetVehicleData"; +} // namespace + +policy_table::Table LoadPreloadedPT(const std::string& filename) { + std::ifstream ifile(filename); + EXPECT_TRUE(ifile.good()); + Json::CharReaderBuilder reader_builder; + Json::Value root(Json::objectValue); + Json::parseFromStream(reader_builder, ifile, &root, nullptr); + root["policy_table"]["module_config"].removeMember("preloaded_pt"); + ifile.close(); + policy_table::Table table(&root); + return table; +} + +Json::Value GetDefaultSnapshotModuleMeta(policy_table::Table& policy_table) { + auto json_table = policy_table.ToJsonValue(); + + Json::Value default_module_meta = json_table["policy_table"]["module_meta"]; + default_module_meta["ccpu_version"] = Json::Value(""); + default_module_meta["hardware_version"] = Json::Value(""); + default_module_meta["language"] = Json::Value(""); + default_module_meta["wers_country_code"] = Json::Value(""); + default_module_meta["pt_exchanged_at_odometer_x"] = Json::Value(0); + default_module_meta["pt_exchanged_x_days_after_epoch"] = Json::Value(0); + default_module_meta["ignition_cycles_since_last_exchange"] = Json::Value(0); + default_module_meta["vin"] = Json::Value(""); + return default_module_meta; +} + class SQLPTExtRepresentationTest : public ::testing::Test { public: // Collection of pairs of group alias and corresponding group name @@ -264,163 +304,147 @@ ::testing::AssertionResult IsValid(const policy_table::Table& table) { } TEST_F(SQLPTExtRepresentationTest, - DISABLED_GenerateSnapshot_SetPolicyTable_SnapshotIsPresent) { - // TODO(AKutsan): APPLINK-31526 Test requires initial preloaded pt for - // preloaded date reading - // Arrange - Json::Value table(Json::objectValue); - table["policy_table"] = Json::Value(Json::objectValue); + GenerateSnapshot_DefaultContentOfModuleMeta_MetaInfoPresentInSnapshot) { + policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson); - Json::Value& policy_table = table["policy_table"]; - policy_table["module_config"] = Json::Value(Json::objectValue); - policy_table["functional_groupings"] = Json::Value(Json::objectValue); - policy_table["consumer_friendly_messages"] = Json::Value(Json::objectValue); - policy_table["app_policies"] = Json::Value(Json::objectValue); - - Json::Value& module_config = policy_table["module_config"]; - module_config["preloaded_date"] = Json::Value(""); - module_config["exchange_after_x_ignition_cycles"] = Json::Value(10); - module_config["exchange_after_x_kilometers"] = Json::Value(100); - module_config["exchange_after_x_days"] = Json::Value(5); - module_config["timeout_after_x_seconds"] = Json::Value(500); - module_config["seconds_between_retries"] = Json::Value(Json::arrayValue); - module_config["seconds_between_retries"][0] = Json::Value(10); - module_config["seconds_between_retries"][1] = Json::Value(20); - module_config["seconds_between_retries"][2] = Json::Value(30); - module_config["endpoints"] = Json::Value(Json::objectValue); - module_config["endpoints"]["0x00"] = Json::Value(Json::objectValue); - module_config["endpoints"]["0x00"]["default"] = Json::Value(Json::arrayValue); - module_config["endpoints"]["0x00"]["default"][0] = - Json::Value("http://ford.com/cloud/default"); - module_config["notifications_per_minute_by_priority"] = - Json::Value(Json::objectValue); - module_config["notifications_per_minute_by_priority"]["emergency"] = - Json::Value(1); - module_config["notifications_per_minute_by_priority"]["navigation"] = - Json::Value(2); - module_config["notifications_per_minute_by_priority"]["VOICECOMM"] = - Json::Value(3); - module_config["notifications_per_minute_by_priority"]["communication"] = - Json::Value(4); - module_config["notifications_per_minute_by_priority"]["normal"] = - Json::Value(5); - module_config["notifications_per_minute_by_priority"]["none"] = - Json::Value(6); - module_config["subtle_notifications_per_minute_by_priority"] = - Json::Value(Json::objectValue); - module_config["subtle_notifications_per_minute_by_priority"]["emergency"] = - Json::Value(7); - module_config["subtle_notifications_per_minute_by_priority"]["navigation"] = - Json::Value(8); - module_config["subtle_notifications_per_minute_by_priority"]["VOICECOMM"] = - Json::Value(9); - module_config["subtle_notifications_per_minute_by_priority"] - ["communication"] = Json::Value(10); - module_config["subtle_notifications_per_minute_by_priority"]["normal"] = - Json::Value(11); - module_config["subtle_notifications_per_minute_by_priority"]["none"] = - Json::Value(12); - module_config["vehicle_make"] = Json::Value("MakeT"); - module_config["vehicle_model"] = Json::Value("ModelT"); - module_config["vehicle_year"] = Json::Value("2014"); - module_config["certificate"] = Json::Value("my_cert"); + ASSERT_TRUE(IsValid(update)); + EXPECT_TRUE(reps_->Save(update)); - Json::Value& functional_groupings = policy_table["functional_groupings"]; - functional_groupings["default"] = Json::Value(Json::objectValue); - Json::Value& default_group = functional_groupings["default"]; - default_group["rpcs"] = Json::Value(Json::objectValue); - default_group["rpcs"]["Update"] = Json::Value(Json::objectValue); - default_group["rpcs"]["Update"]["hmi_levels"] = Json::Value(Json::arrayValue); - default_group["rpcs"]["Update"]["hmi_levels"][0] = Json::Value("FULL"); - default_group["rpcs"]["Update"]["parameters"] = Json::Value(Json::arrayValue); - default_group["rpcs"]["Update"]["parameters"][0] = Json::Value("speed"); - - Json::Value& consumer_friendly_messages = - policy_table["consumer_friendly_messages"]; - consumer_friendly_messages["version"] = Json::Value("1.2"); - consumer_friendly_messages["messages"] = Json::Value(Json::objectValue); - consumer_friendly_messages["messages"]["MSG1"] = - Json::Value(Json::objectValue); - Json::Value& msg1 = consumer_friendly_messages["messages"]["MSG1"]; - msg1["languages"] = Json::Value(Json::objectValue); - msg1["languages"]["en-us"] = Json::Value(Json::objectValue); - msg1["languages"]["en-us"]["tts"] = Json::Value("TTS message"); - msg1["languages"]["en-us"]["label"] = Json::Value("LABEL message"); - msg1["languages"]["en-us"]["line1"] = Json::Value("LINE1 message"); - msg1["languages"]["en-us"]["line2"] = Json::Value("LINE2 message"); - msg1["languages"]["en-us"]["textBody"] = Json::Value("TEXTBODY message"); - - Json::Value& app_policies = policy_table["app_policies"]; - app_policies["default"] = Json::Value(Json::objectValue); - app_policies["default"]["memory_kb"] = Json::Value(50); - app_policies["default"]["heart_beat_timeout_ms"] = Json::Value(100); - app_policies["default"]["groups"] = Json::Value(Json::arrayValue); - app_policies["default"]["groups"][0] = Json::Value("default"); - app_policies["default"]["priority"] = Json::Value("EMERGENCY"); - app_policies["default"]["default_hmi"] = Json::Value("FULL"); - app_policies["default"]["keep_context"] = Json::Value(true); - app_policies["default"]["steal_focus"] = Json::Value(true); - app_policies["pre_DataConsent"] = Json::Value(Json::objectValue); - app_policies["pre_DataConsent"]["memory_kb"] = Json::Value(50); - app_policies["pre_DataConsent"]["heart_beat_timeout_ms"] = Json::Value(100); - app_policies["pre_DataConsent"]["groups"] = Json::Value(Json::arrayValue); - app_policies["pre_DataConsent"]["groups"][0] = Json::Value("default"); - app_policies["pre_DataConsent"]["priority"] = Json::Value("EMERGENCY"); - app_policies["pre_DataConsent"]["default_hmi"] = Json::Value("FULL"); - app_policies["pre_DataConsent"]["keep_context"] = Json::Value(true); - app_policies["pre_DataConsent"]["steal_focus"] = Json::Value(true); - app_policies["1234"] = Json::Value(Json::objectValue); - app_policies["1234"]["memory_kb"] = Json::Value(50); - app_policies["1234"]["heart_beat_timeout_ms"] = Json::Value(100); - app_policies["1234"]["groups"] = Json::Value(Json::arrayValue); - app_policies["1234"]["groups"][0] = Json::Value("default"); - app_policies["1234"]["priority"] = Json::Value("EMERGENCY"); - app_policies["1234"]["default_hmi"] = Json::Value("FULL"); - app_policies["1234"]["keep_context"] = Json::Value(true); - app_policies["1234"]["steal_focus"] = Json::Value(true); - app_policies["device"] = Json::Value(Json::objectValue); - app_policies["device"]["groups"] = Json::Value(Json::arrayValue); - app_policies["device"]["groups"][0] = Json::Value("default"); - app_policies["device"]["priority"] = Json::Value("EMERGENCY"); - app_policies["device"]["default_hmi"] = Json::Value("FULL"); - app_policies["device"]["keep_context"] = Json::Value(true); - app_policies["device"]["steal_focus"] = Json::Value(true); - - policy_table::Table update(&table); - update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE); + std::shared_ptr snapshot = reps_->GenerateSnapshot(); + + auto expected_module_meta = GetDefaultSnapshotModuleMeta(update); + auto& snapshot_module_meta = snapshot->policy_table.module_meta; + EXPECT_EQ(expected_module_meta.toStyledString(), + snapshot_module_meta.ToJsonValue().toStyledString()); +} + +TEST_F( + SQLPTExtRepresentationTest, + GenerateSnapshot_SetMandatoryMetaInfo_MandatoryMetaInfoIsPresentInSnapshot) { + policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson); - // Assert ASSERT_TRUE(IsValid(update)); ASSERT_TRUE(reps_->Save(update)); - // Act + EXPECT_TRUE( + reps_->SetMetaInfo(kSoftwareVersion, kWersCountryCode, kLanguage)); + std::shared_ptr snapshot = reps_->GenerateSnapshot(); - snapshot->SetPolicyTableType(rpc::policy_table_interface_base::PT_SNAPSHOT); - policy_table["module_meta"] = Json::Value(Json::objectValue); - policy_table["usage_and_error_counts"] = Json::Value(Json::objectValue); - policy_table["device_data"] = Json::Value(Json::objectValue); - policy_table["module_config"]["preloaded_pt"] = Json::Value(false); + auto expected_module_meta = GetDefaultSnapshotModuleMeta(update); + expected_module_meta["ccpu_version"] = Json::Value(kSoftwareVersion); + expected_module_meta["language"] = Json::Value(kLanguage); + expected_module_meta["wers_country_code"] = Json::Value(kWersCountryCode); - Json::Value& module_meta = policy_table["module_meta"]; - module_meta["ccpu_version"] = Json::Value(""); - module_meta["language"] = Json::Value(""); - module_meta["wers_country_code"] = Json::Value(""); - module_meta["pt_exchanged_at_odometer_x"] = Json::Value(0); - module_meta["pt_exchanged_x_days_after_epoch"] = Json::Value(0); - module_meta["ignition_cycles_since_last_exchange"] = Json::Value(0); - module_meta["vin"] = Json::Value(""); + auto& snapshot_module_meta = snapshot->policy_table.module_meta; + EXPECT_EQ(expected_module_meta.toStyledString(), + snapshot_module_meta.ToJsonValue().toStyledString()); +} - Json::Value& usage_and_error_counts = policy_table["usage_and_error_counts"]; - usage_and_error_counts["count_of_iap_buffer_full"] = Json::Value(0); - usage_and_error_counts["count_sync_out_of_memory"] = Json::Value(0); - usage_and_error_counts["count_of_sync_reboots"] = Json::Value(0); +TEST_F(SQLPTExtRepresentationTest, + GenerateSnapshot_SetHardwareVersion_HardwareVersionIsPresentInSnapshot) { + policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson); - policy_table::Table expected(&table); + ASSERT_TRUE(IsValid(update)); + EXPECT_TRUE(reps_->Save(update)); - // Assert - EXPECT_EQ(expected.ToJsonValue().toStyledString(), - snapshot->ToJsonValue().toStyledString()); + reps_->SetHardwareVersion(kHardwareVersion); + std::shared_ptr snapshot = reps_->GenerateSnapshot(); + + auto expected_module_meta = GetDefaultSnapshotModuleMeta(update); + expected_module_meta["hardware_version"] = Json::Value(kHardwareVersion); + + auto& snapshot_module_meta = snapshot->policy_table.module_meta; + EXPECT_EQ(expected_module_meta.toStyledString(), + snapshot_module_meta.ToJsonValue().toStyledString()); +} + +TEST_F(SQLPTExtRepresentationTest, Save_ParametersPresent_ParametersSaved) { + policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson); + ASSERT_TRUE(IsValid(update)); + + policy_table::FunctionalGroupings func_groups; + ASSERT_TRUE(reps_->GetFunctionalGroupings(func_groups)); + EXPECT_TRUE(func_groups.empty()); + + EXPECT_TRUE(reps_->Save(update)); + ASSERT_TRUE(reps_->GetFunctionalGroupings(func_groups)); + + policy_table::FunctionalGroupings::iterator func_groups_iter = + func_groups.find(kFunctionalGroupWithParams); + ASSERT_TRUE(func_groups.end() != func_groups_iter); + policy_table::Rpcs& rpcs = func_groups_iter->second; + EXPECT_EQ(kUserConsentForGroupWithParams, + static_cast(*rpcs.user_consent_prompt)); + policy_table::Rpc& rpc = rpcs.rpcs; + policy_table::Rpc::const_iterator rpc_iter = rpc.find(kRpcForGroupWithParams); + EXPECT_TRUE(rpc.end() != rpc_iter); + const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters); + EXPECT_TRUE(!parameters.empty()); +} + +TEST_F(SQLPTExtRepresentationTest, Save_NoParameters_NoParametersSaved) { + policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson); + ASSERT_TRUE(IsValid(update)); + + policy_table::FunctionalGroupings func_groups; + ASSERT_TRUE(reps_->GetFunctionalGroupings(func_groups)); + EXPECT_TRUE(func_groups.empty()); + + EXPECT_TRUE(reps_->Save(update)); + ASSERT_TRUE(reps_->GetFunctionalGroupings(func_groups)); + + const std::string func_group_without_params = "Notifications"; + const std::string user_consent = "Notifications"; + const std::string rpc_without_params = "Alert"; + + policy_table::FunctionalGroupings::iterator func_groups_iter = + func_groups.find(func_group_without_params); + ASSERT_TRUE(func_groups.end() != func_groups_iter); + policy_table::Rpcs& rpcs = func_groups_iter->second; + EXPECT_EQ(user_consent, static_cast(*rpcs.user_consent_prompt)); + policy_table::Rpc& rpc = rpcs.rpcs; + EXPECT_EQ(1u, rpc.size()); + policy_table::Rpc::const_iterator rpc_iter = rpc.find(rpc_without_params); + EXPECT_TRUE(rpc.end() != rpc_iter); + // Check parameters + const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters); + EXPECT_FALSE(parameters.is_initialized()); + EXPECT_TRUE(parameters.empty()); +} + +TEST_F(SQLPTExtRepresentationTest, Save_EmptyParameters_ParametersEmpty) { + policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson); + ASSERT_TRUE(IsValid(update)); + + policy_table::FunctionalGroupings func_groups; + EXPECT_TRUE(reps_->GetFunctionalGroupings(func_groups)); + EXPECT_TRUE(func_groups.empty()); + + auto json_update = update.ToJsonValue(); + json_update["policy_table"]["functional_groupings"] + [kFunctionalGroupWithParams]["rpcs"][kRpcForGroupWithParams] + ["parameters"] = Json::Value(Json::arrayValue); + policy_table::Table update_with_empty_param(&json_update); + + EXPECT_TRUE(reps_->Save(update_with_empty_param)); + EXPECT_TRUE(reps_->GetFunctionalGroupings(func_groups)); + + policy_table::FunctionalGroupings::iterator func_groups_iter = + func_groups.find(kFunctionalGroupWithParams); + ASSERT_TRUE(func_groups.end() != func_groups_iter); + policy_table::Rpcs& rpcs = func_groups_iter->second; + EXPECT_EQ(kUserConsentForGroupWithParams, + static_cast(*rpcs.user_consent_prompt)); + policy_table::Rpc& rpc = rpcs.rpcs; + policy_table::Rpc::const_iterator rpc_iter = rpc.find(kRpcForGroupWithParams); + EXPECT_TRUE(rpc.end() != rpc_iter); + // Check parameters + const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters); + // 'parameters' : [] - represented as initialized, but empty + // missing 'parameters' - represented as non-initialized and empty + EXPECT_TRUE(parameters.is_initialized()); + EXPECT_TRUE(parameters.empty()); } TEST_F( @@ -1159,7 +1183,8 @@ TEST_F( TEST_F(SQLPTExtRepresentationTest, SetMetaInfo_SetMetaInfo_ExpectValuesSetInParams) { // Arrange - ASSERT_TRUE(reps_->SetMetaInfo("4.1.3.B_EB355B", "WAEGB", "ru-ru")); + ASSERT_TRUE( + reps_->SetMetaInfo(kSoftwareVersion, kWersCountryCode, kLanguage)); utils::dbms::SQLQuery query(reps_->db()); const std::string query_select_ccpu = "SELECT `ccpu_version` FROM `module_meta`"; @@ -1171,13 +1196,13 @@ TEST_F(SQLPTExtRepresentationTest, // Assert query.Prepare(query_select_ccpu); query.Next(); - EXPECT_EQ("4.1.3.B_EB355B", query.GetString(0)); + EXPECT_EQ(kSoftwareVersion, query.GetString(0)); query.Prepare(query_select_wers_country_code); query.Next(); - EXPECT_EQ("WAEGB", query.GetString(0)); + EXPECT_EQ(kWersCountryCode, query.GetString(0)); query.Prepare(query_select_language); query.Next(); - EXPECT_EQ("ru-ru", query.GetString(0)); + EXPECT_EQ(kLanguage, query.GetString(0)); } TEST_F(SQLPTExtRepresentationTest, @@ -1203,6 +1228,17 @@ TEST_F(SQLPTExtRepresentationTest, EXPECT_EQ("ru-ru", query.GetString(0)); } +TEST_F(SQLPTExtRepresentationTest, SetHardwareVersion_ValueIsSetInModuleMeta) { + utils::dbms::SQLQuery query(reps_->db()); + reps_->SetHardwareVersion(kHardwareVersion); + const std::string query_select_hardware_version = + "SELECT `hardware_version` FROM `module_meta`"; + + query.Prepare(query_select_hardware_version); + query.Next(); + EXPECT_EQ(kHardwareVersion, query.GetString(0)); +} + TEST_F( SQLPTExtRepresentationTest, GetFunctionalGroupNames_SetGroupsManuallyThenGetGroupNames_ExpectAllGroupsReceived) { 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 224c663c524..1adf9ae7c62 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 @@ -188,150 +188,6 @@ class SQLPTRepresentationTest : public SQLPTRepresentation, StringsCompare(groups, app_groups); } - void PolicyTableUpdatePrepare(Json::Value& table) { - PolicyTableUpdatePrepareNoParameters(table); - - table["policy_table"]["functional_groupings"]["default"]["rpcs"]["Update"] - ["parameters"] = Json::Value(Json::arrayValue); - table["policy_table"]["functional_groupings"]["default"]["rpcs"]["Update"] - ["parameters"][0] = Json::Value("speed"); - } - - void PolicyTableUpdatePrepareEmptyParameters(Json::Value& table) { - PolicyTableUpdatePrepareNoParameters(table); - - // Parameters are empty - table["policy_table"]["functional_groupings"]["default"]["rpcs"]["Update"] - ["parameters"] = Json::Value(Json::arrayValue); - } - - void PolicyTableUpdatePrepareNoParameters(Json::Value& table) { - table["policy_table"] = Json::Value(Json::objectValue); - Json::Value& policy_table = table["policy_table"]; - policy_table["module_config"] = Json::Value(Json::objectValue); - policy_table["functional_groupings"] = Json::Value(Json::objectValue); - policy_table["consumer_friendly_messages"] = Json::Value(Json::objectValue); - policy_table["app_policies"] = Json::Value(Json::objectValue); - - Json::Value& module_config = policy_table["module_config"]; - module_config["preloaded_date"] = Json::Value("25-04-2015"); - module_config["exchange_after_x_ignition_cycles"] = Json::Value(10); - module_config["exchange_after_x_kilometers"] = Json::Value(100); - module_config["exchange_after_x_days"] = Json::Value(5); - module_config["timeout_after_x_seconds"] = Json::Value(500); - module_config["seconds_between_retries"] = Json::Value(Json::arrayValue); - Json::Value& seconds_between_retries = - module_config["seconds_between_retries"]; - seconds_between_retries[0] = Json::Value(10); - seconds_between_retries[1] = Json::Value(20); - seconds_between_retries[2] = Json::Value(30); - module_config["endpoints"] = Json::Value(Json::objectValue); - Json::Value& endpoins = module_config["endpoints"]; - endpoins["0x00"] = Json::Value(Json::objectValue); - endpoins["0x00"]["default"] = Json::Value(Json::arrayValue); - endpoins["0x00"]["default"][0] = - Json::Value("http://ford.com/cloud/default"); - module_config["notifications_per_minute_by_priority"] = - Json::Value(Json::objectValue); - module_config["notifications_per_minute_by_priority"]["emergency"] = - Json::Value(1); - module_config["notifications_per_minute_by_priority"]["navigation"] = - Json::Value(2); - module_config["notifications_per_minute_by_priority"]["VOICECOMM"] = - Json::Value(3); - module_config["notifications_per_minute_by_priority"]["communication"] = - Json::Value(4); - module_config["notifications_per_minute_by_priority"]["normal"] = - Json::Value(5); - module_config["notifications_per_minute_by_priority"]["none"] = - Json::Value(6); - module_config["subtle_notifications_per_minute_by_priority"] = - Json::Value(Json::objectValue); - module_config["subtle_notifications_per_minute_by_priority"]["emergency"] = - Json::Value(7); - module_config["subtle_notifications_per_minute_by_priority"]["navigation"] = - Json::Value(8); - module_config["subtle_notifications_per_minute_by_priority"]["VOICECOMM"] = - Json::Value(9); - module_config["subtle_notifications_per_minute_by_priority"] - ["communication"] = Json::Value(10); - module_config["subtle_notifications_per_minute_by_priority"]["normal"] = - Json::Value(11); - module_config["subtle_notifications_per_minute_by_priority"]["none"] = - Json::Value(12); - module_config["vehicle_make"] = Json::Value("MakeT"); - module_config["vehicle_model"] = Json::Value("ModelT"); - module_config["vehicle_year"] = Json::Value("2014"); - module_config["certificate"] = Json::Value("my_cert"); - - Json::Value& functional_groupings = policy_table["functional_groupings"]; - functional_groupings["default"] = Json::Value(Json::objectValue); - Json::Value& default_group = functional_groupings["default"]; - default_group["rpcs"] = Json::Value(Json::objectValue); - default_group["rpcs"]["Update"] = Json::Value(Json::objectValue); - default_group["rpcs"]["Update"]["hmi_levels"] = - Json::Value(Json::arrayValue); - default_group["rpcs"]["Update"]["hmi_levels"][0] = Json::Value("FULL"); - // No parameters - - Json::Value& consumer_friendly_messages = - policy_table["consumer_friendly_messages"]; - consumer_friendly_messages["version"] = Json::Value("1.2"); - consumer_friendly_messages["messages"] = Json::Value(Json::objectValue); - consumer_friendly_messages["messages"]["MSG1"] = - Json::Value(Json::objectValue); - Json::Value& msg1 = consumer_friendly_messages["messages"]["MSG1"]; - msg1["languages"] = Json::Value(Json::objectValue); - msg1["languages"]["en-us"] = Json::Value(Json::objectValue); - msg1["languages"]["en-us"]["tts"] = Json::Value("TTS message"); - msg1["languages"]["en-us"]["label"] = Json::Value("LABEL message"); - msg1["languages"]["en-us"]["line1"] = Json::Value("LINE1 message"); - msg1["languages"]["en-us"]["line2"] = Json::Value("LINE2 message"); - msg1["languages"]["en-us"]["textBody"] = Json::Value("TEXTBODY message"); - - Json::Value& app_policies = policy_table["app_policies"]; - app_policies["default"] = Json::Value(Json::objectValue); - app_policies["default"]["priority"] = Json::Value("EMERGENCY"); - app_policies["default"]["memory_kb"] = Json::Value(50); - app_policies["default"]["heart_beat_timeout_ms"] = Json::Value(100); - app_policies["default"]["groups"] = Json::Value(Json::arrayValue); - app_policies["default"]["groups"][0] = Json::Value("default"); - app_policies["default"]["priority"] = Json::Value("EMERGENCY"); - app_policies["default"]["is_revoked"] = Json::Value(true); - app_policies["default"]["default_hmi"] = Json::Value("FULL"); - app_policies["default"]["keep_context"] = Json::Value(true); - app_policies["default"]["steal_focus"] = Json::Value(true); - - app_policies["pre_DataConsent"] = Json::Value(Json::objectValue); - app_policies["pre_DataConsent"]["memory_kb"] = Json::Value(40); - app_policies["pre_DataConsent"]["heart_beat_timeout_ms"] = Json::Value(90); - app_policies["pre_DataConsent"]["groups"] = Json::Value(Json::arrayValue); - app_policies["pre_DataConsent"]["groups"][0] = Json::Value("default"); - app_policies["pre_DataConsent"]["priority"] = Json::Value("EMERGENCY"); - app_policies["pre_DataConsent"]["default_hmi"] = Json::Value("FULL"); - app_policies["pre_DataConsent"]["is_revoked"] = Json::Value(false); - app_policies["pre_DataConsent"]["keep_context"] = Json::Value(true); - app_policies["pre_DataConsent"]["steal_focus"] = Json::Value(true); - app_policies["1234"] = Json::Value(Json::objectValue); - app_policies["1234"]["memory_kb"] = Json::Value(150); - app_policies["1234"]["heart_beat_timeout_ms"] = Json::Value(200); - app_policies["1234"]["groups"] = Json::Value(Json::arrayValue); - app_policies["1234"]["groups"][0] = Json::Value("default"); - app_policies["1234"]["priority"] = Json::Value("EMERGENCY"); - app_policies["1234"]["default_hmi"] = Json::Value("FULL"); - app_policies["1234"]["is_revoked"] = Json::Value(true); - app_policies["1234"]["keep_context"] = Json::Value(false); - app_policies["1234"]["steal_focus"] = Json::Value(false); - app_policies["device"] = Json::Value(Json::objectValue); - app_policies["device"]["groups"] = Json::Value(Json::arrayValue); - app_policies["device"]["groups"][0] = Json::Value("default"); - app_policies["device"]["priority"] = Json::Value("EMERGENCY"); - app_policies["device"]["is_revoked"] = Json::Value(true); - app_policies["device"]["default_hmi"] = Json::Value("FULL"); - app_policies["device"]["keep_context"] = Json::Value(true); - app_policies["device"]["steal_focus"] = Json::Value(true); - } - ::testing::AssertionResult IsValid(const policy_table::Table& table) { if (table.is_valid()) { return ::testing::AssertionSuccess(); @@ -1633,304 +1489,6 @@ TEST(SQLPTRepresentationTest3, RemoveDB_RemoveDB_ExpectFileDeleted) { EXPECT_FALSE(file_system::FileExists(path)); } -TEST_F(SQLPTRepresentationTest, - DISABLED_GenerateSnapshot_SetPolicyTable_SnapshotIsPresent) { - // TODO(AKutsan):APPLINK-31526 Test requires initial preloaded pt for - // preloaded date reading - // Arrange - Json::Value table(Json::objectValue); - PolicyTableUpdatePrepare(table); - - policy_table::Table update(&table); - update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE); - - // Assert - ASSERT_TRUE(IsValid(update)); - ASSERT_TRUE(reps->Save(update)); - - // Act - std::shared_ptr snapshot = reps->GenerateSnapshot(); - snapshot->SetPolicyTableType(rpc::policy_table_interface_base::PT_SNAPSHOT); - // Remove fields which must be absent in snapshot - table["policy_table"]["consumer_friendly_messages"].removeMember("messages"); - table["policy_table"]["app_policies"]["1234"].removeMember("default_hmi"); - table["policy_table"]["app_policies"]["1234"].removeMember("keep_context"); - table["policy_table"]["app_policies"]["1234"].removeMember("steal_focus"); - table["policy_table"]["app_policies"]["default"].removeMember("default_hmi"); - table["policy_table"]["app_policies"]["default"].removeMember("keep_context"); - table["policy_table"]["app_policies"]["default"].removeMember("steal_focus"); - table["policy_table"]["app_policies"]["pre_DataConsent"].removeMember( - "default_hmi"); - table["policy_table"]["app_policies"]["pre_DataConsent"].removeMember( - "keep_context"); - table["policy_table"]["app_policies"]["pre_DataConsent"].removeMember( - "steal_focus"); - table["policy_table"]["app_policies"]["device"].removeMember("default_hmi"); - table["policy_table"]["app_policies"]["device"].removeMember("keep_context"); - table["policy_table"]["app_policies"]["device"].removeMember("steal_focus"); - table["policy_table"]["app_policies"]["device"].removeMember("groups"); - table["policy_table"]["device_data"] = Json::Value(Json::objectValue); - table["policy_table"]["module_meta"] = Json::Value(Json::objectValue); - table["policy_table"]["module_config"]["preloaded_pt"] = Json::Value(false); - policy_table::Table expected(&table); - Json::StreamWriterBuilder writer_builder; - // Checks - Json::Value snapshot_json_value = snapshot->ToJsonValue(); - EXPECT_EQ(Json::writeString(writer_builder, expected.ToJsonValue()), - Json::writeString(writer_builder, snapshot_json_value)); - std::cout << Json::writeString(writer_builder, snapshot_json_value) - << std::endl; - EXPECT_EQ(expected.ToJsonValue().toStyledString(), - snapshot_json_value.toStyledString()); -} - -TEST_F(SQLPTRepresentationTest, - DISABLED_Save_SetPolicyTableThenSave_ExpectSavedToPT) { - // TODO(AKutsan): APPLINK-31526 Test requires initial preloaded pt for - // preloaded date reading - // Arrange - Json::Value table(Json::objectValue); - PolicyTableUpdatePrepare(table); - - policy_table::Table update(&table); - update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE); - // Checks PT before Save - policy_table::FunctionalGroupings func_groups; - ASSERT_TRUE(reps->GetFunctionalGroupings(func_groups)); - // Check functional groupings section - EXPECT_EQ(0u, func_groups.size()); - - policy_table::ApplicationPoliciesSection policies; - GatherApplicationPoliciesSection(&policies); - // Check ApplicationPoliciesSection - EXPECT_EQ(0u, policies.apps.size()); - EXPECT_EQ(0u, (policies.device.preconsented_groups)->size()); - EXPECT_EQ(0u, policies.device.groups.size()); - EXPECT_EQ(policy_table::Priority::P_EMERGENCY, policies.device.priority); - EXPECT_EQ(policy_table::HmiLevel::HL_BACKGROUND, policies.device.default_hmi); - EXPECT_FALSE(policies.device.keep_context); - EXPECT_FALSE(policies.device.steal_focus); - - policy_table::ModuleConfig config; - GatherModuleConfig(&config); - // Check Module config section - EXPECT_TRUE(*config.preloaded_pt); - EXPECT_EQ(0, config.exchange_after_x_ignition_cycles); - EXPECT_EQ(0, config.exchange_after_x_kilometers); - EXPECT_EQ(0, config.exchange_after_x_days); - EXPECT_EQ(0, config.timeout_after_x_seconds); - EXPECT_EQ("", static_cast(*config.vehicle_make)); - EXPECT_EQ("", static_cast(*config.vehicle_model)); - EXPECT_EQ("", static_cast(*config.vehicle_year)); - EXPECT_EQ("", static_cast(*config.preloaded_date)); - EXPECT_EQ("", static_cast(*config.certificate)); - EXPECT_EQ(0u, config.seconds_between_retries.size()); - EXPECT_EQ(0u, config.endpoints.size()); - EXPECT_EQ(0u, config.notifications_per_minute_by_priority.size()); - EXPECT_EQ(0u, (*config.subtle_notifications_per_minute_by_priority).size()); - - policy_table::ConsumerFriendlyMessages messages; - GatherConsumerFriendlyMessages(&messages); - EXPECT_EQ("0", static_cast(messages.version)); - policy_table::DeviceData devices; - GatherDeviceData(&devices); - EXPECT_EQ(0u, devices.size()); - policy_table::UsageAndErrorCounts counts; - GatherUsageAndErrorCounts(&counts); - EXPECT_EQ(0u, counts.app_level->size()); - ASSERT_TRUE(IsValid(update)); - // Act - ASSERT_TRUE(reps->Save(update)); - - // Check Functional Groupings - ASSERT_TRUE(reps->GetFunctionalGroupings(func_groups)); - // Checks - EXPECT_EQ(1u, func_groups.size()); - policy_table::FunctionalGroupings::iterator func_groups_iter = - func_groups.find("default"); - ASSERT_TRUE(func_groups.end() != func_groups_iter); - policy_table::Rpcs& rpcs = func_groups_iter->second; - EXPECT_EQ("", static_cast(*rpcs.user_consent_prompt)); - policy_table::Rpc& rpc = rpcs.rpcs; - EXPECT_EQ(1u, rpc.size()); - policy_table::Rpc::const_iterator rpc_iter = rpc.find("Update"); - EXPECT_TRUE(rpc.end() != rpc_iter); - const policy_table::HmiLevels& hmi_levels = rpc_iter->second.hmi_levels; - EXPECT_EQ(1u, hmi_levels.size()); - EXPECT_TRUE(hmi_levels.end() != std::find(hmi_levels.begin(), - hmi_levels.end(), - policy_table::HmiLevel::HL_FULL)); - - const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters); - EXPECT_EQ(1u, parameters.size()); - EXPECT_TRUE(parameters.end() != - std::find(parameters.begin(), parameters.end(), "P_SPEED")); - // Check Application Policies Section - GatherApplicationPoliciesSection(&policies); - const uint32_t apps_size = 3u; - - rpc::String<1ul, 255ul> str("default"); - policy_table::Strings groups; - groups.push_back(str); - CheckAppPoliciesSection(policies, - apps_size, - policy_table::Priority::P_EMERGENCY, - "1234", - 150u, - 200u, - groups); - CheckAppPoliciesSection(policies, - apps_size, - policy_table::Priority::P_EMERGENCY, - "default", - 50u, - 100u, - groups); - CheckAppPoliciesSection(policies, - apps_size, - policy_table::Priority::P_EMERGENCY, - "pre_DataConsent", - 40u, - 90u, - groups); - CheckAppPoliciesSection(policies, - apps_size, - policy_table::Priority::P_EMERGENCY, - "device", - 0u, - 0u, - groups); - EXPECT_EQ(0u, (policies.device.preconsented_groups)->size()); - EXPECT_EQ(0u, policies.device.groups.size()); - EXPECT_EQ(policy_table::HmiLevel::HL_BACKGROUND, policies.device.default_hmi); - EXPECT_FALSE(policies.device.keep_context); - EXPECT_FALSE(policies.device.steal_focus); - - CheckAppGroups("1234", groups); - CheckAppGroups("default", groups); - CheckAppGroups("pre_DataConsent", groups); - CheckAppGroups("device", groups); - - GatherModuleConfig(&config); - // Check Module Config section - ASSERT_FALSE(*config.preloaded_pt); - ASSERT_EQ("my_cert", static_cast(*config.certificate)); - ASSERT_EQ("25-04-2015", static_cast(*config.preloaded_date)); - ASSERT_EQ("2014", static_cast(*config.vehicle_year)); - ASSERT_EQ("ModelT", static_cast(*config.vehicle_model)); - ASSERT_EQ("MakeT", static_cast(*config.vehicle_make)); - ASSERT_EQ(10, config.exchange_after_x_ignition_cycles); - ASSERT_EQ(100, config.exchange_after_x_kilometers); - ASSERT_EQ(5, config.exchange_after_x_days); - ASSERT_EQ(500, config.timeout_after_x_seconds); - ASSERT_EQ(3u, config.seconds_between_retries.size()); - ASSERT_EQ(10, config.seconds_between_retries[0]); - ASSERT_EQ(20, config.seconds_between_retries[1]); - ASSERT_EQ(30, config.seconds_between_retries[2]); - ASSERT_EQ(6u, config.notifications_per_minute_by_priority.size()); - ASSERT_EQ(1, config.notifications_per_minute_by_priority["emergency"]); - ASSERT_EQ(2, config.notifications_per_minute_by_priority["navigation"]); - ASSERT_EQ(3, config.notifications_per_minute_by_priority["VOICECOMM"]); - ASSERT_EQ(4, config.notifications_per_minute_by_priority["communication"]); - ASSERT_EQ(5, config.notifications_per_minute_by_priority["normal"]); - ASSERT_EQ(6, config.notifications_per_minute_by_priority["none"]); - ASSERT_EQ(6u, (*config.subtle_notifications_per_minute_by_priority).size()); - ASSERT_EQ(7, - (*config.subtle_notifications_per_minute_by_priority)["emergency"]); - ASSERT_EQ( - 8, (*config.subtle_notifications_per_minute_by_priority)["navigation"]); - ASSERT_EQ(9, - (*config.subtle_notifications_per_minute_by_priority)["VOICECOMM"]); - ASSERT_EQ( - 10, - (*config.subtle_notifications_per_minute_by_priority)["communication"]); - ASSERT_EQ(11, - (*config.subtle_notifications_per_minute_by_priority)["normal"]); - ASSERT_EQ(12, (*config.subtle_notifications_per_minute_by_priority)["none"]); - EXPECT_EQ(1u, config.endpoints.size()); - policy_table::ServiceEndpoints& service_endpoints = config.endpoints; - EXPECT_EQ("0x00", service_endpoints.begin()->first); - policy_table::URLList& url_list = service_endpoints.begin()->second; - EXPECT_EQ("default", url_list.begin()->first); - policy_table::URL& url = url_list.begin()->second; - EXPECT_EQ("http://ford.com/cloud/default", static_cast(url[0])); - GatherConsumerFriendlyMessages(&messages); - EXPECT_EQ("1.2", static_cast(messages.version)); -} - -TEST_F(SQLPTRepresentationTest, - Save_SavePolicyTable_EmptyParameters_ParametersEMPTY) { - // Arrange - Json::Value table(Json::objectValue); - PolicyTableUpdatePrepareEmptyParameters(table); - - policy_table::Table update(&table); - update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE); - // Checks PT before Save - policy_table::FunctionalGroupings func_groups; - ASSERT_TRUE(reps->GetFunctionalGroupings(func_groups)); - // Check functional groupings section - EXPECT_EQ(0u, func_groups.size()); - - // Act - ASSERT_TRUE(reps->Save(update)); - - // Check Functional Groupings - ASSERT_TRUE(reps->GetFunctionalGroupings(func_groups)); - // Checks - EXPECT_EQ(1u, func_groups.size()); - policy_table::FunctionalGroupings::iterator func_groups_iter = - func_groups.find("default"); - ASSERT_TRUE(func_groups.end() != func_groups_iter); - policy_table::Rpcs& rpcs = func_groups_iter->second; - EXPECT_EQ("", static_cast(*rpcs.user_consent_prompt)); - policy_table::Rpc& rpc = rpcs.rpcs; - EXPECT_EQ(1u, rpc.size()); - policy_table::Rpc::const_iterator rpc_iter = rpc.find("Update"); - EXPECT_TRUE(rpc.end() != rpc_iter); - // Check parameters - const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters); - // 'parameters' : [] - represented as initialized, but empty - // missing 'parameters' - represented as non-initialized and empty - EXPECT_TRUE(parameters.is_initialized()); - EXPECT_TRUE(parameters.empty()); -} - -TEST_F(SQLPTRepresentationTest, - Save_SavePolicyTable_NoParameters_NoParametersSaved) { - // Arrange - Json::Value table(Json::objectValue); - PolicyTableUpdatePrepareNoParameters(table); - - policy_table::Table update(&table); - update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE); - // Checks PT before Save - policy_table::FunctionalGroupings func_groups; - ASSERT_TRUE(reps->GetFunctionalGroupings(func_groups)); - // Check functional groupings section - EXPECT_EQ(0u, func_groups.size()); - - // Act - ASSERT_TRUE(reps->Save(update)); - - // Check Functional Groupings - ASSERT_TRUE(reps->GetFunctionalGroupings(func_groups)); - // Checks - EXPECT_EQ(1u, func_groups.size()); - policy_table::FunctionalGroupings::iterator func_groups_iter = - func_groups.find("default"); - ASSERT_TRUE(func_groups.end() != func_groups_iter); - policy_table::Rpcs& rpcs = func_groups_iter->second; - EXPECT_EQ("", static_cast(*rpcs.user_consent_prompt)); - policy_table::Rpc& rpc = rpcs.rpcs; - EXPECT_EQ(1u, rpc.size()); - policy_table::Rpc::const_iterator rpc_iter = rpc.find("Update"); - EXPECT_TRUE(rpc.end() != rpc_iter); - // Check parameters - const ::policy_table::Parameters& parameters = *(rpc_iter->second.parameters); - EXPECT_EQ(0u, parameters.size()); -} - } // namespace policy_test } // namespace components } // namespace test 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 29952bd18e0..c5b8f78c773 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 @@ -37,6 +37,7 @@ #include "policy/policy_manager_impl.h" #include "utils/conditional_variable.h" +#include "utils/test_async_waiter.h" namespace test { namespace components { @@ -78,44 +79,6 @@ class UpdateStatusManagerTest : public ::testing::Test { void TearDown() OVERRIDE {} }; -namespace { -/** - * @brief The WaitAsync class - * can wait for a certain amount of function calls from different - * threads, or a timeout expires. - */ -class WaitAsync { - public: - WaitAsync(const uint32_t count, const uint32_t timeout) - : count_(count), timeout_(timeout) {} - - void Notify() { - count_--; - cond_var_.NotifyOne(); - } - - bool Wait(sync_primitives::AutoLock& auto_lock) { - while (count_ > 0) { - sync_primitives::ConditionalVariable::WaitStatus wait_status = - cond_var_.WaitFor(auto_lock, timeout_); - if (wait_status == sync_primitives::ConditionalVariable::kTimeout) { - return false; - } - } - return true; - } - - private: - int count_; - 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); @@ -124,18 +87,17 @@ ACTION_P2(RetryFailed, manager, listener) { TEST_F(UpdateStatusManagerTest, OnUpdateSentOut_WaitForTimeoutExpired_ExpectStatusUpdateNeeded) { // Arrange - 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); + auto waiter = TestAsyncWaiter::createInstance(); + EXPECT_CALL(listener_, OnUpdateStatusChanged(_)) - .WillRepeatedly(NotifyAsync(&waiter)); + .WillRepeatedly(NotifyTestAsyncWaiter(waiter)); manager_->ScheduleUpdate(); manager_->OnUpdateSentOut(k_timeout_); status_ = manager_->GetLastUpdateStatus(); EXPECT_EQ(StatusUpdatePending, status_); - EXPECT_TRUE(waiter.Wait(auto_lock)); + EXPECT_TRUE(waiter->WaitFor(count, timeout)); status_ = manager_->GetLastUpdateStatus(); // Check EXPECT_EQ(StatusUpdateRequired, status_); @@ -148,9 +110,9 @@ TEST_F( sync_primitives::AutoLock auto_lock(lock); const uint32_t count = 3u; const uint32_t timeout = 2u * k_timeout_; - WaitAsync waiter(count, timeout); + auto waiter = TestAsyncWaiter::createInstance(); EXPECT_CALL(listener_, OnUpdateStatusChanged(_)) - .WillRepeatedly(NotifyAsync(&waiter)); + .WillRepeatedly(NotifyTestAsyncWaiter(waiter)); EXPECT_CALL(mock_ptu_retry_handler_, RetrySequenceFailed()) .WillOnce(RetryFailed(manager_, &listener_)); manager_->ScheduleUpdate(); @@ -167,7 +129,7 @@ TEST_F( EXPECT_CALL(listener_, OnPTUFinished(false)); } EXPECT_EQ(StatusUpdatePending, status_); - EXPECT_TRUE(waiter.Wait(auto_lock)); + EXPECT_TRUE(waiter->WaitFor(count, timeout)); status_ = manager_->GetLastUpdateStatus(); // Check EXPECT_EQ(StatusUpdateRequired, status_); 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 25b4a8bc180..473caef1450 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -544,13 +544,11 @@ class CacheManager : public CacheManagerInterface { */ void SetPreloadedPtFlag(const bool is_preloaded) OVERRIDE; - /** - * @brief Records information about head unit system to PT - * @return bool Success of operation - */ bool SetMetaInfo(const std::string& ccpu_version, const std::string& wers_country_code, - const std::string& language); + const std::string& language) OVERRIDE; + + void SetHardwareVersion(const std::string& hardware_version) OVERRIDE; /** * @brief Get information about last ccpu_version from PT @@ -558,6 +556,8 @@ class CacheManager : public CacheManagerInterface { */ std::string GetCCPUVersionFromPT() const; + std::string GetHardwareVersionFromPT() const OVERRIDE; + /** * @brief Checks, if specific head unit is present in PT * @return boot Suceess, if present, otherwise - false 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 14130c03162..5e536ef3156 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 @@ -586,19 +586,31 @@ class CacheManagerInterface { virtual void SetPreloadedPtFlag(const bool is_preloaded) = 0; /** - * @brief Records information about head unit system to PT + * @brief Records mandatory information about head unit system to PT * @return bool Success of operation */ virtual bool SetMetaInfo(const std::string& ccpu_version, const std::string& wers_country_code, const std::string& language) = 0; + /** + * @brief Records information about hardware version to PT + * @param hardware_version Hardware version + */ + virtual void SetHardwareVersion(const std::string& hardware_version) = 0; + /** * @brief Get information about last ccpu_version from PT * @return ccpu_version from PT */ virtual std::string GetCCPUVersionFromPT() const = 0; + /** + * @brief Get information about last hardware version from PT + * @return string representation of hardware version from PT, empty if absent + */ + virtual std::string GetHardwareVersionFromPT() const = 0; + /** * @brief Checks, if specific head unit is present in PT * @return boot Suceess, if present, otherwise - false 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 dff4802d827..32c546df622 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 @@ -451,10 +451,14 @@ class PolicyManagerImpl : public PolicyManager { const std::string& wers_country_code, const std::string& language) OVERRIDE; + void SetHardwareVersion(const std::string& hardware_version) OVERRIDE; + void SetPreloadedPtFlag(const bool is_preloaded) OVERRIDE; std::string GetCCPUVersionFromPT() const OVERRIDE; + std::string GetHardwareVersionFromPT() const OVERRIDE; + /** * @brief Get number of notification by priority * @param priority Specified priority 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 673f17e32bd..7eeb41f064f 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 @@ -430,6 +430,7 @@ struct ModuleMeta : CompositeType { Optional > pt_exchanged_x_days_after_epoch; Optional > ignition_cycles_since_last_exchange; Optional > ccpu_version; + Optional > hardware_version; public: ModuleMeta(); 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 7f95d9132b6..fe54da6b18b 100644 --- a/src/components/policy/policy_regular/include/policy/policy_types.h +++ b/src/components/policy/policy_regular/include/policy/policy_types.h @@ -280,6 +280,7 @@ struct AppPermissions { , appRevoked(false) , appPermissionsConsentNeeded(false) , appUnauthorized(false) + , isSDLAllowed(false) , requestTypeChanged(false) , requestSubTypeChanged(false) {} 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 895b4ea6b57..9a57ed21adc 100644 --- a/src/components/policy/policy_regular/include/policy/pt_representation.h +++ b/src/components/policy/policy_regular/include/policy/pt_representation.h @@ -152,11 +152,17 @@ class PTRepresentation { virtual EndpointUrls GetUpdateUrls(int service_type) = 0; /** - * @brief Records information about head unit system to PT + * @brief Records mandatory information about head unit system to PT * @return bool Success of operation */ virtual bool SetMetaInfo(const std::string& ccpu_version) = 0; + /** + * @brief Records information about hardware version to PT + * @param hardware_version Hardware version + */ + virtual void SetHardwareVersion(const std::string& hardware_version) = 0; + /** * @brief Get allowed number of notifications * depending on application priority. 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 5bf85a4bb5c..fd7f879abf4 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 @@ -145,6 +145,7 @@ extern const std::string kUpdateDBVersion; extern const std::string kSaveModuleMeta; extern const std::string kSelectModuleMeta; extern const std::string kUpdateMetaParams; +extern const std::string kUpdateMetaHardwareVersion; extern const std::string kInsertVehicleDataItem; extern const std::string kSelectVehicleDataItem; extern const std::string kDeleteVehicleDataItems; 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 512bfd63269..18147c43f0d 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 @@ -90,7 +90,8 @@ class SQLPTRepresentation : public virtual PTRepresentation { StringArray* nicknames = NULL, StringArray* app_hmi_types = NULL); bool GetFunctionalGroupings(policy_table::FunctionalGroupings& groups); - bool SetMetaInfo(const std::string& ccpu_version); + bool SetMetaInfo(const std::string& ccpu_version) OVERRIDE; + void SetHardwareVersion(const std::string& hardware_version) OVERRIDE; #ifdef BUILD_TESTS uint32_t open_counter() { return open_counter_; diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 8f989966874..cf4164d1338 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -1128,7 +1128,8 @@ bool CacheManager::GetPriority(const std::string& policy_app_id, policy_table::ApplicationPolicies::const_iterator policy_iter = policies.find(policy_app_id); - const bool app_id_exists = policies.end() != policy_iter; + const bool app_id_exists = + policies.end() != policy_iter && !IsApplicationRevoked(policy_app_id); if (app_id_exists) { priority = EnumToJsonString((*policy_iter).second.priority); } @@ -1336,6 +1337,8 @@ void CacheManager::PersistData() { } backup_->SetMetaInfo(*(*copy_pt.policy_table.module_meta).ccpu_version); + backup_->SetHardwareVersion( + *(*copy_pt.policy_table.module_meta).hardware_version); // In case of extended policy the meta info should be backuped as well. backup_->WriteDb(); @@ -1489,13 +1492,35 @@ bool CacheManager::SetMetaInfo(const std::string& ccpu_version, return true; } +void CacheManager::SetHardwareVersion(const std::string& hardware_version) { + SDL_LOG_AUTO_TRACE(); + CACHE_MANAGER_CHECK_VOID(); + sync_primitives::AutoLock auto_lock(cache_lock_); + + *pt_->policy_table.module_meta->hardware_version = hardware_version; + Backup(); +} + std::string CacheManager::GetCCPUVersionFromPT() const { SDL_LOG_AUTO_TRACE(); + CACHE_MANAGER_CHECK(std::string("")); + sync_primitives::AutoLock auto_lock(cache_lock_); + rpc::Optional& module_meta = pt_->policy_table.module_meta; return *(module_meta->ccpu_version); } +std::string CacheManager::GetHardwareVersionFromPT() const { + SDL_LOG_AUTO_TRACE(); + CACHE_MANAGER_CHECK(std::string("")); + sync_primitives::AutoLock auto_lock(cache_lock_); + + rpc::Optional& module_meta = + pt_->policy_table.module_meta; + return *(module_meta->hardware_version); +} + bool CacheManager::IsMetaInfoPresent() const { CACHE_MANAGER_CHECK(false); bool result = true; 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 059375322a5..b6101eb960a 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -1217,11 +1217,22 @@ void PolicyManagerImpl::SetSystemInfo(const std::string& ccpu_version, cache_->SetMetaInfo(ccpu_version, wers_country_code, language); } +void PolicyManagerImpl::SetHardwareVersion( + const std::string& hardware_version) { + SDL_LOG_AUTO_TRACE(); + cache_->SetHardwareVersion(hardware_version); +} + std::string PolicyManagerImpl::GetCCPUVersionFromPT() const { SDL_LOG_AUTO_TRACE(); return cache_->GetCCPUVersionFromPT(); } +std::string PolicyManagerImpl::GetHardwareVersionFromPT() const { + SDL_LOG_AUTO_TRACE(); + return cache_->GetHardwareVersionFromPT(); +} + uint32_t PolicyManagerImpl::GetNotificationsNumber(const std::string& priority, const bool is_subtle) const { SDL_LOG_AUTO_TRACE(); 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 d3473bb2a7a..d2a70baafee 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -1297,7 +1297,8 @@ ModuleMeta::ModuleMeta(const Json::Value* value__) impl::ValueMember(value__, "pt_exchanged_x_days_after_epoch")) , ignition_cycles_since_last_exchange( impl::ValueMember(value__, "ignition_cycles_since_last_exchange")) - , ccpu_version(impl::ValueMember(value__, "ccpu_version")) {} + , ccpu_version(impl::ValueMember(value__, "ccpu_version")) + , hardware_version(impl::ValueMember(value__, "hardware_version")) {} Json::Value ModuleMeta::ToJsonValue() const { Json::Value result__(Json::objectValue); @@ -1319,6 +1320,9 @@ bool ModuleMeta::is_valid() const { if (!ccpu_version.is_valid()) { return false; } + if (!hardware_version.is_valid()) { + return false; + } if (!pt_exchanged_at_odometer_x.is_valid()) { return false; } @@ -1339,6 +1343,9 @@ bool ModuleMeta::struct_empty() const { if (ccpu_version.is_initialized()) { return false; } + if (hardware_version.is_initialized()) { + return false; + } if (pt_exchanged_at_odometer_x.is_initialized()) { return false; } @@ -1359,6 +1366,10 @@ void ModuleMeta::ReportErrors(rpc::ValidationReport* report__) const { if (!ccpu_version.is_valid()) { ccpu_version.ReportErrors(&report__->ReportSubobject("ccpu_version")); } + if (!hardware_version.is_valid()) { + hardware_version.ReportErrors( + &report__->ReportSubobject("hardware_version")); + } if (!pt_exchanged_at_odometer_x.is_valid()) { pt_exchanged_at_odometer_x.ReportErrors( &report__->ReportSubobject("pt_exchanged_at_odometer_x")); 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 cf9167406f6..ea0b7fe997b 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -60,7 +60,8 @@ const std::string kCreateSchema = " `pt_exchanged_x_days_after_epoch` INTEGER NOT NULL DEFAULT 0, " " `ignition_cycles_since_last_exchange` INTEGER NOT NULL DEFAULT 0, " " `flag_update_required` BOOL NOT NULL, " - " `ccpu_version` VARCHAR(45) " + " `ccpu_version` VARCHAR(45), " + " `hardware_version` VARCHAR(45) " "); " "CREATE TABLE IF NOT EXISTS `module_config`( " " `preloaded_pt` BOOL NOT NULL, " @@ -1076,10 +1077,16 @@ const std::string kSaveModuleMeta = "`pt_exchanged_x_days_after_epoch` = ?, " "`ignition_cycles_since_last_exchange` = ? "; -const std::string kSelectModuleMeta = "SELECT* FROM `module_meta`"; +const std::string kSelectModuleMeta = + "SELECT `ccpu_version`, `hardware_version`, `pt_exchanged_at_odometer_x`, " + "`pt_exchanged_x_days_after_epoch`, `ignition_cycles_since_last_exchange` " + "FROM `module_meta`"; const std::string kUpdateMetaParams = "UPDATE `module_meta` SET " "`ccpu_version` = ? "; + +const std::string kUpdateMetaHardwareVersion = + "UPDATE `module_meta` SET `hardware_version` = ? "; } // 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 7193a06bdb3..57781ae16f8 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -472,10 +472,11 @@ void SQLPTRepresentation::GatherModuleMeta( SDL_LOG_INFO("Gather Module Meta Info"); utils::dbms::SQLQuery query(db()); if (query.Prepare(sql_pt::kSelectModuleMeta) && query.Next()) { - *meta->pt_exchanged_at_odometer_x = query.GetInteger(0); - *meta->pt_exchanged_x_days_after_epoch = query.GetInteger(1); - *meta->ignition_cycles_since_last_exchange = query.GetInteger(2); - *meta->ccpu_version = query.GetString(4); + *meta->ccpu_version = query.GetString(0); + *meta->hardware_version = query.GetString(1); + *meta->pt_exchanged_at_odometer_x = query.GetInteger(2); + *meta->pt_exchanged_x_days_after_epoch = query.GetInteger(3); + *meta->ignition_cycles_since_last_exchange = query.GetInteger(4); } } @@ -716,6 +717,22 @@ bool SQLPTRepresentation::SetMetaInfo(const std::string& ccpu_version) { return true; } +void SQLPTRepresentation::SetHardwareVersion( + const std::string& hardware_version) { + SDL_LOG_AUTO_TRACE(); + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kUpdateMetaHardwareVersion)) { + SDL_LOG_WARN("Incorrect statement for insert to module meta."); + return; + } + + query.Bind(0, hardware_version); + + if (!query.Exec()) { + SDL_LOG_WARN("Incorrect insert to module meta."); + } +} + bool SQLPTRepresentation::GatherApplicationPoliciesSection( policy_table::ApplicationPoliciesSection* policies) const { SDL_LOG_INFO("Gather applications policies"); diff --git a/src/components/policy/policy_regular/test/CMakeLists.txt b/src/components/policy/policy_regular/test/CMakeLists.txt index d2cd7be2243..cdd6cc98dad 100644 --- a/src/components/policy/policy_regular/test/CMakeLists.txt +++ b/src/components/policy/policy_regular/test/CMakeLists.txt @@ -49,6 +49,7 @@ file (GLOB POLICY_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/policy_manager_impl_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/access_remote_impl_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/sql_pt_representation_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/sql_pt_representation_storage_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/update_status_manager_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/vehicle_data_item_type_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/shared_library_test.cc diff --git a/src/components/policy/policy_regular/test/cache_manager_test.cc b/src/components/policy/policy_regular/test/cache_manager_test.cc index 31166b8f434..00b632ac17e 100644 --- a/src/components/policy/policy_regular/test/cache_manager_test.cc +++ b/src/components/policy/policy_regular/test/cache_manager_test.cc @@ -1235,6 +1235,18 @@ TEST_F(CacheManagerTest, IsApplicationRepresented_DeviceApp_ReturnTrue) { EXPECT_TRUE(cache_manager_->IsApplicationRepresented(kDeviceId)); } +TEST_F(CacheManagerTest, GetHardwareVersion_ValueWasSetBefore_ReturnValue) { + std::string hardware_version = "1.1.1.1"; + cache_manager_->SetHardwareVersion(hardware_version); + EXPECT_EQ(hardware_version, cache_manager_->GetHardwareVersionFromPT()); +} + +TEST_F(CacheManagerTest, + GetHardwareVersion_ValueNotSettedBefore_ReturnEmptyString) { + std::string empty_string = ""; + EXPECT_EQ(empty_string, cache_manager_->GetHardwareVersionFromPT()); +} + } // namespace policy_test } // namespace components } // namespace test 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 d5a66f43882..c4565613285 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 @@ -599,20 +599,6 @@ TEST_F(PolicyManagerImplTest, GetHMITypes_ValidHmiTypes_ReturnTrue) { EXPECT_TRUE(policy_manager_->GetHMITypes(kValidAppId, &app_types)); } -TEST_F(PolicyManagerImplTest, SetMetaInfo_SetCCPUVersion_SUCCESS) { - const std::string ccpu_version = "ccpu_version"; - const std::string wers_country_code = "wersCountryCode"; - const std::string language = "language"; - - EXPECT_CALL(*mock_cache_manager_, - SetMetaInfo(ccpu_version, wers_country_code, language)); - policy_manager_->SetSystemInfo(ccpu_version, wers_country_code, language); - - EXPECT_CALL(*mock_cache_manager_, GetCCPUVersionFromPT()) - .WillOnce(Return(ccpu_version)); - EXPECT_EQ(ccpu_version, policy_manager_->GetCCPUVersionFromPT()); -} - } // 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 f4efa811b68..fb64dfe7d0a 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 @@ -72,6 +72,35 @@ namespace policy_test { using policy_handler_test::MockPolicySettings; +namespace { +const std::string kSdlPreloadedPtJson = "json/sdl_preloaded_pt.json"; +const std::string kSoftwareVersion = "4.1.3.B_EB355B"; +const std::string kHardwareVersion = "1.1.1.0"; +} // namespace + +policy_table::Table LoadPreloadedPT(const std::string& filename) { + std::ifstream ifile(filename); + EXPECT_TRUE(ifile.good()); + Json::CharReaderBuilder reader_builder; + Json::Value root(Json::objectValue); + Json::parseFromStream(reader_builder, ifile, &root, nullptr); + root["policy_table"]["module_config"].removeMember("preloaded_pt"); + ifile.close(); + policy_table::Table table(&root); + return table; +} + +Json::Value GetDefaultSnapshotModuleMeta(policy_table::Table& policy_table) { + auto json_table = policy_table.ToJsonValue(); + + Json::Value default_module_meta = json_table["policy_table"]["module_meta"]; + default_module_meta["pt_exchanged_at_odometer_x"] = Json::Value(0); + default_module_meta["pt_exchanged_x_days_after_epoch"] = Json::Value(0); + default_module_meta["ignition_cycles_since_last_exchange"] = Json::Value(0); + + return default_module_meta; +} + class SQLPTRepresentationTest : protected SQLPTRepresentation, public ::testing::Test { protected: @@ -201,180 +230,6 @@ class SQLPTRepresentationTest : protected SQLPTRepresentation, StringsCompare(groups, app_groups); } - void PolicyTableUpdatePrepare(Json::Value& table) { - // Root - table["policy_table"] = Json::Value(Json::objectValue); - - // 1st level - Json::Value& policy_table = table["policy_table"]; - policy_table["module_config"] = Json::Value(Json::objectValue); - policy_table["functional_groupings"] = Json::Value(Json::objectValue); - policy_table["consumer_friendly_messages"] = Json::Value(Json::objectValue); - policy_table["app_policies"] = Json::Value(Json::objectValue); - policy_table["usage_and_error_counts"] = Json::Value(Json::objectValue); - policy_table["device_data"] = Json::Value(Json::objectValue); - - // 'module_config' section start - Json::Value& module_config = policy_table["module_config"]; - module_config["preloaded_pt"] = Json::Value(false); - module_config["preloaded_date"] = Json::Value(""); - module_config["exchange_after_x_ignition_cycles"] = Json::Value(10); - module_config["exchange_after_x_kilometers"] = Json::Value(100); - module_config["exchange_after_x_days"] = Json::Value(5); - module_config["timeout_after_x_seconds"] = Json::Value(500); - module_config["seconds_between_retries"] = Json::Value(Json::arrayValue); - - Json::Value& seconds_between_retries = - module_config["seconds_between_retries"]; - seconds_between_retries[0] = Json::Value(10); - seconds_between_retries[1] = Json::Value(20); - seconds_between_retries[2] = Json::Value(30); - module_config["endpoints"] = Json::Value(Json::objectValue); - - Json::Value& endpoins = module_config["endpoints"]; - endpoins["0x00"] = Json::Value(Json::objectValue); - endpoins["0x00"]["default"] = Json::Value(Json::arrayValue); - endpoins["0x00"]["default"][0] = - Json::Value("http://ford.com/cloud/default"); - module_config["notifications_per_minute_by_priority"] = - Json::Value(Json::objectValue); - module_config["notifications_per_minute_by_priority"]["emergency"] = - Json::Value(1); - module_config["notifications_per_minute_by_priority"]["navigation"] = - Json::Value(2); - module_config["notifications_per_minute_by_priority"]["VOICECOMM"] = - Json::Value(3); - module_config["notifications_per_minute_by_priority"]["communication"] = - Json::Value(4); - module_config["notifications_per_minute_by_priority"]["normal"] = - Json::Value(5); - module_config["notifications_per_minute_by_priority"]["none"] = - Json::Value(6); - module_config["subtle_notifications_per_minute_by_priority"] = - Json::Value(Json::objectValue); - module_config["subtle_notifications_per_minute_by_priority"]["emergency"] = - Json::Value(7); - module_config["subtle_notifications_per_minute_by_priority"]["navigation"] = - Json::Value(8); - module_config["subtle_notifications_per_minute_by_priority"]["VOICECOMM"] = - Json::Value(9); - module_config["subtle_notifications_per_minute_by_priority"] - ["communication"] = Json::Value(10); - module_config["subtle_notifications_per_minute_by_priority"]["normal"] = - Json::Value(11); - module_config["subtle_notifications_per_minute_by_priority"]["none"] = - Json::Value(12); - module_config["vehicle_make"] = Json::Value(""); - module_config["vehicle_model"] = Json::Value(""); - module_config["vehicle_year"] = Json::Value(""); - module_config["certificate"] = Json::Value("encrypted_certificate_content"); - // 'module_config' section end - - // 'functional_groupings' section start - Json::Value& functional_groupings = policy_table["functional_groupings"]; - functional_groupings["default"] = Json::Value(Json::objectValue); - Json::Value& default_group = functional_groupings["default"]; - default_group["rpcs"] = Json::Value(Json::objectValue); - default_group["rpcs"]["Update"] = Json::Value(Json::objectValue); - default_group["rpcs"]["Update"]["hmi_levels"] = - Json::Value(Json::arrayValue); - default_group["rpcs"]["Update"]["hmi_levels"][0] = Json::Value("FULL"); - default_group["rpcs"]["Update"]["parameters"] = - Json::Value(Json::arrayValue); - default_group["rpcs"]["Update"]["parameters"][0] = Json::Value("speed"); - - Json::Value& consumer_friendly_messages = - policy_table["consumer_friendly_messages"]; - consumer_friendly_messages["version"] = Json::Value("some_msg_version"); - consumer_friendly_messages["messages"] = Json::Value(Json::objectValue); - consumer_friendly_messages["messages"]["MSG_CODE"] = - Json::Value(Json::objectValue); - Json::Value& msg1 = consumer_friendly_messages["messages"]["MSG_CODE"]; - msg1["languages"] = Json::Value(Json::objectValue); - msg1["languages"]["en-us"] = Json::Value(Json::objectValue); - // 'functional_groupings' section end - - // 'app_policies' section start - Json::Value& app_policies = policy_table["app_policies"]; - app_policies["default"] = Json::Value(Json::objectValue); - app_policies["default"]["priority"] = Json::Value("EMERGENCY"); - app_policies["default"]["memory_kb"] = Json::Value(50); - app_policies["default"]["heart_beat_timeout_ms"] = Json::Value(100); - app_policies["default"]["groups"] = Json::Value(Json::arrayValue); - app_policies["default"]["groups"][0] = Json::Value("default"); - app_policies["default"]["priority"] = Json::Value("EMERGENCY"); - app_policies["default"]["is_revoked"] = Json::Value(true); - app_policies["default"]["default_hmi"] = Json::Value("FULL"); - app_policies["default"]["keep_context"] = Json::Value(true); - app_policies["default"]["steal_focus"] = Json::Value(true); - app_policies["default"]["RequestType"] = Json::Value(Json::arrayValue); - - app_policies["pre_DataConsent"] = Json::Value(Json::objectValue); - app_policies["pre_DataConsent"]["memory_kb"] = Json::Value(40); - app_policies["pre_DataConsent"]["heart_beat_timeout_ms"] = Json::Value(90); - app_policies["pre_DataConsent"]["groups"] = Json::Value(Json::arrayValue); - app_policies["pre_DataConsent"]["groups"][0] = Json::Value("default"); - app_policies["pre_DataConsent"]["priority"] = Json::Value("EMERGENCY"); - app_policies["pre_DataConsent"]["default_hmi"] = Json::Value("FULL"); - app_policies["pre_DataConsent"]["is_revoked"] = Json::Value(false); - app_policies["pre_DataConsent"]["keep_context"] = Json::Value(true); - app_policies["pre_DataConsent"]["steal_focus"] = Json::Value(true); - app_policies["pre_DataConsent"]["RequestType"] = - Json::Value(Json::arrayValue); - - app_policies["1234"] = Json::Value(Json::objectValue); - app_policies["1234"]["memory_kb"] = Json::Value(150); - app_policies["1234"]["heart_beat_timeout_ms"] = Json::Value(200); - app_policies["1234"]["groups"] = Json::Value(Json::arrayValue); - app_policies["1234"]["groups"][0] = Json::Value("default"); - app_policies["1234"]["priority"] = Json::Value("EMERGENCY"); - app_policies["1234"]["default_hmi"] = Json::Value("FULL"); - app_policies["1234"]["is_revoked"] = Json::Value(true); - app_policies["1234"]["keep_context"] = Json::Value(false); - 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"] = - Json::Value(Json::arrayValue); - app_policies["1234"]["app_services"]["MEDIA"]["service_names"][0] = - Json::Value("SDL App"); - app_policies["1234"]["app_services"]["MEDIA"]["service_names"][1] = - Json::Value("SDL Music"); - app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"] = - Json::Value(Json::arrayValue); - app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"][0] = - Json::Value(Json::objectValue); - app_policies["1234"]["app_services"]["MEDIA"]["handled_rpcs"][0] - ["function_id"] = Json::Value(41); - - app_policies["device"] = Json::Value(Json::objectValue); - app_policies["device"]["groups"] = Json::Value(Json::arrayValue); - app_policies["device"]["groups"][0] = Json::Value("default"); - app_policies["device"]["priority"] = Json::Value("EMERGENCY"); - app_policies["device"]["is_revoked"] = Json::Value(true); - app_policies["device"]["default_hmi"] = Json::Value("FULL"); - app_policies["device"]["keep_context"] = Json::Value(true); - app_policies["device"]["steal_focus"] = Json::Value(true); - // 'app_policies' section end - - Json::Value& usage_and_error_counts = - policy_table["usage_and_error_counts"]; - usage_and_error_counts["app_level"] = Json::Value(Json::objectValue); - usage_and_error_counts["app_level"]["some_app_id"] = - Json::Value(Json::objectValue); - usage_and_error_counts["app_level"]["some_app_id"]["count_of_tls_errors"] = - Json::Value(5); - - Json::Value& device_data = policy_table["device_data"]; - device_data["device_id_hash_1"] = Json::Value(Json::objectValue); - device_data["device_id_hash_2"] = Json::Value(Json::objectValue); - device_data["device_id_hash_3"] = Json::Value(Json::objectValue); - } - ::testing::AssertionResult IsValid(const policy_table::Table& table) { if (table.is_valid()) { return ::testing::AssertionSuccess(); @@ -1812,252 +1667,77 @@ TEST_F(SQLPTRepresentationTest3, RemoveDB_RemoveDB_ExpectFileDeleted) { EXPECT_FALSE(file_system::FileExists(path)); } -// TODO {AKozoriz} : Snapshot must have module meta section, but test -// generates snapshot without it. TEST_F(SQLPTRepresentationTest, - DISABLED_GenerateSnapshot_SetPolicyTable_SnapshotIsPresent) { - // Arrange - Json::Value table(Json::objectValue); - PolicyTableUpdatePrepare(table); + GenerateSnapshot_DefaultContentOfModuleMeta_MetaInfoPresentInSnapshot) { + policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson); - policy_table::Table update(&table); - update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE); + ASSERT_TRUE(IsValid(update)); + EXPECT_TRUE(reps->Save(update)); - // Assert - // ASSERT_TRUE(IsValid(update)); - ASSERT_TRUE(reps->Save(update)); + std::shared_ptr snapshot = reps->GenerateSnapshot(); + + auto expected_module_meta = GetDefaultSnapshotModuleMeta(update); + auto& snapshot_module_meta = snapshot->policy_table.module_meta; + EXPECT_EQ(expected_module_meta.toStyledString(), + snapshot_module_meta.ToJsonValue().toStyledString()); +} + +TEST_F(SQLPTRepresentationTest, + GenerateSnapshot_SetMetaInfo_NoSoftwareVersionInSnapshot) { + policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson); + + ASSERT_TRUE(IsValid(update)); + EXPECT_TRUE(reps->Save(update)); + EXPECT_TRUE(reps->SetMetaInfo(kSoftwareVersion)); - // Act std::shared_ptr snapshot = reps->GenerateSnapshot(); - snapshot->SetPolicyTableType(rpc::policy_table_interface_base::PT_SNAPSHOT); - // Remove fields which must be absent in snapshot - table["policy_table"]["consumer_friendly_messages"].removeMember("messages"); - table["policy_table"]["app_policies"]["1234"].removeMember("default_hmi"); - table["policy_table"]["app_policies"]["1234"].removeMember("keep_context"); - table["policy_table"]["app_policies"]["1234"].removeMember("steal_focus"); - table["policy_table"]["app_policies"]["default"].removeMember("default_hmi"); - table["policy_table"]["app_policies"]["default"].removeMember("keep_context"); - table["policy_table"]["app_policies"]["default"].removeMember("steal_focus"); - table["policy_table"]["app_policies"]["pre_DataConsent"].removeMember( - "default_hmi"); - table["policy_table"]["app_policies"]["pre_DataConsent"].removeMember( - "keep_context"); - table["policy_table"]["app_policies"]["pre_DataConsent"].removeMember( - "steal_focus"); - table["policy_table"]["app_policies"]["device"].removeMember("default_hmi"); - table["policy_table"]["app_policies"]["device"].removeMember("keep_context"); - table["policy_table"]["app_policies"]["device"].removeMember("steal_focus"); - table["policy_table"]["app_policies"]["device"].removeMember("groups"); - table["policy_table"]["device_data"] = Json::Value(Json::objectValue); - table["policy_table"]["module_meta"] = Json::Value(Json::objectValue); - policy_table::Table expected(&table); - Json::StreamWriterBuilder writer_builder; - // Checks - EXPECT_EQ(Json::writeString(writer_builder, expected.ToJsonValue()), - Json::writeString(writer_builder, snapshot->ToJsonValue())); - EXPECT_EQ(expected.ToJsonValue().toStyledString(), - snapshot->ToJsonValue().toStyledString()); + + auto expected_module_meta = GetDefaultSnapshotModuleMeta(update); + auto& snapshot_module_meta = snapshot->policy_table.module_meta; + EXPECT_EQ(expected_module_meta.toStyledString(), + snapshot_module_meta.ToJsonValue().toStyledString()); } -TEST_F(SQLPTRepresentationTest, Save_SetPolicyTableThenSave_ExpectSavedToPT) { - // Arrange - Json::Value table(Json::objectValue); - PolicyTableUpdatePrepare(table); +TEST_F(SQLPTRepresentationTest, + GenerateSnapshot_SetHardwareVersion_NoHardwareVersionInSnapshot) { + policy_table::Table update = LoadPreloadedPT(kSdlPreloadedPtJson); - policy_table::Table update(&table); - update.SetPolicyTableType(rpc::policy_table_interface_base::PT_UPDATE); - // Checks PT before Save - policy_table::FunctionalGroupings func_groups; - ASSERT_TRUE(reps->GetFunctionalGroupings(func_groups)); - // Check functional groupings section - EXPECT_EQ(0u, func_groups.size()); - - policy_table::ApplicationPoliciesSection policies; - GatherApplicationPoliciesSection(&policies); - // Check ApplicationPoliciesSection - EXPECT_EQ(0u, policies.apps.size()); - EXPECT_EQ(policy_table::Priority::P_EMERGENCY, policies.device.priority); - - policy_table::ModuleConfig config; - GatherModuleConfig(&config); - // Check Module config section - EXPECT_TRUE(*config.preloaded_pt); - EXPECT_EQ(0, config.exchange_after_x_ignition_cycles); - EXPECT_EQ(0, config.exchange_after_x_kilometers); - EXPECT_EQ(0, config.exchange_after_x_days); - EXPECT_EQ(0, config.timeout_after_x_seconds); - EXPECT_EQ("", static_cast(*config.vehicle_make)); - EXPECT_EQ("", static_cast(*config.vehicle_model)); - EXPECT_EQ("", static_cast(*config.vehicle_year)); - EXPECT_EQ("", static_cast(*config.preloaded_date)); - EXPECT_EQ("", static_cast(*config.certificate)); - EXPECT_EQ(0u, config.seconds_between_retries.size()); - EXPECT_EQ(0u, config.endpoints.size()); - EXPECT_EQ(0u, config.notifications_per_minute_by_priority.size()); - EXPECT_EQ(0u, (*config.subtle_notifications_per_minute_by_priority).size()); - - policy_table::ConsumerFriendlyMessages messages; - GatherConsumerFriendlyMessages(&messages); - EXPECT_EQ("0", static_cast(messages.version)); - - policy_table::DeviceData devices; - GatherDeviceData(&devices); - EXPECT_EQ(0u, devices.size()); - - policy_table::UsageAndErrorCounts counts; - GatherUsageAndErrorCounts(&counts); - EXPECT_TRUE(0u == counts.app_level->size()); - - // ASSERT_TRUE(IsValid(update)); - // Act - ASSERT_TRUE(reps->Save(update)); + ASSERT_TRUE(IsValid(update)); + EXPECT_TRUE(reps->Save(update)); + reps->SetHardwareVersion(kHardwareVersion); - // Check Functional Groupings - ASSERT_TRUE(reps->GetFunctionalGroupings(func_groups)); - // Checks - EXPECT_EQ(1u, func_groups.size()); - policy_table::FunctionalGroupings::iterator func_groups_iter = - func_groups.find("default"); - ASSERT_TRUE(func_groups.end() != func_groups_iter); - policy_table::Rpcs& rpcs = func_groups_iter->second; - EXPECT_EQ("", static_cast(*rpcs.user_consent_prompt)); - policy_table::Rpc& rpc = rpcs.rpcs; - EXPECT_EQ(1u, rpc.size()); - policy_table::Rpc::const_iterator rpc_iter = rpc.find("Update"); - EXPECT_TRUE(rpc.end() != rpc_iter); - const policy_table::HmiLevels& hmi_levels = rpc_iter->second.hmi_levels; - EXPECT_EQ(1u, hmi_levels.size()); - EXPECT_TRUE(hmi_levels.end() != std::find(hmi_levels.begin(), - hmi_levels.end(), - policy_table::HmiLevel::HL_FULL)); - - 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::EnumToJsonString( - policy_table::Parameter::P_SPEED))); - // Check Application Policies Section - GatherApplicationPoliciesSection(&policies); - const uint32_t apps_size = 3u; - - rpc::String<1ul, 255ul> str("default"); - policy_table::Strings groups; - groups.push_back(str); - CheckAppPoliciesSection(policies, - apps_size, - policy_table::Priority::P_EMERGENCY, - "1234", - 150u, - 200u, - groups); - CheckAppPoliciesSection(policies, - apps_size, - policy_table::Priority::P_EMERGENCY, - "default", - 50u, - 100u, - groups); - CheckAppPoliciesSection(policies, - apps_size, - policy_table::Priority::P_EMERGENCY, - "pre_DataConsent", - 40u, - 90u, - groups); - CheckAppPoliciesSection(policies, - apps_size, - policy_table::Priority::P_EMERGENCY, - "device", - 0u, - 0u, - groups); - - CheckAppGroups("1234", groups); - CheckAppGroups("default", groups); - CheckAppGroups("pre_DataConsent", groups); - - GatherModuleConfig(&config); - // Check Module Config section - ASSERT_FALSE(*config.preloaded_pt); - ASSERT_EQ("encrypted_certificate_content", - static_cast(*config.certificate)); - ASSERT_EQ("", static_cast(*config.preloaded_date)); - ASSERT_EQ("", static_cast(*config.vehicle_year)); - ASSERT_EQ("", static_cast(*config.vehicle_model)); - ASSERT_EQ("", static_cast(*config.vehicle_make)); - ASSERT_EQ(10, config.exchange_after_x_ignition_cycles); - ASSERT_EQ(100, config.exchange_after_x_kilometers); - ASSERT_EQ(5, config.exchange_after_x_days); - ASSERT_EQ(500, config.timeout_after_x_seconds); - ASSERT_EQ(3u, config.seconds_between_retries.size()); - ASSERT_EQ(10, config.seconds_between_retries[0]); - ASSERT_EQ(20, config.seconds_between_retries[1]); - ASSERT_EQ(30, config.seconds_between_retries[2]); - ASSERT_EQ(6u, config.notifications_per_minute_by_priority.size()); - ASSERT_EQ(1, config.notifications_per_minute_by_priority["emergency"]); - ASSERT_EQ(2, config.notifications_per_minute_by_priority["navigation"]); - ASSERT_EQ(3, config.notifications_per_minute_by_priority["VOICECOMM"]); - ASSERT_EQ(4, config.notifications_per_minute_by_priority["communication"]); - ASSERT_EQ(5, config.notifications_per_minute_by_priority["normal"]); - ASSERT_EQ(6, config.notifications_per_minute_by_priority["none"]); - ASSERT_EQ(6u, (*config.subtle_notifications_per_minute_by_priority).size()); - ASSERT_EQ(7, - (*config.subtle_notifications_per_minute_by_priority)["emergency"]); - ASSERT_EQ( - 8, (*config.subtle_notifications_per_minute_by_priority)["navigation"]); - ASSERT_EQ(9, - (*config.subtle_notifications_per_minute_by_priority)["VOICECOMM"]); - ASSERT_EQ( - 10, - (*config.subtle_notifications_per_minute_by_priority)["communication"]); - ASSERT_EQ(11, - (*config.subtle_notifications_per_minute_by_priority)["normal"]); - ASSERT_EQ(12, (*config.subtle_notifications_per_minute_by_priority)["none"]); - EXPECT_EQ(1u, config.endpoints.size()); - policy_table::ServiceEndpoints& service_endpoints = config.endpoints; - EXPECT_EQ("0x00", service_endpoints.begin()->first); - policy_table::URLList& url_list = service_endpoints.begin()->second; - EXPECT_EQ("default", url_list.begin()->first); - policy_table::URL& url = url_list.begin()->second; - EXPECT_EQ("http://ford.com/cloud/default", static_cast(url[0])); - - GatherConsumerFriendlyMessages(&messages); - EXPECT_EQ("some_msg_version", static_cast(messages.version)); - EXPECT_TRUE(0u != messages.messages->size()); - EXPECT_TRUE(0u != (*messages.messages)["MSG_CODE"].languages.size()); - - GatherUsageAndErrorCounts(&counts); - EXPECT_FALSE(0u == counts.app_level->size()); - EXPECT_EQ(5u, (*counts.app_level)["some_app_id"].count_of_tls_errors); - - GatherDeviceData(&devices); - EXPECT_EQ(3u, devices.size()); - - const std::string kAppId = "1234"; - const std::string kServiceType = "MEDIA"; - policy_table::AppServiceParameters app_service_parameters; - GatherAppServiceParameters(kAppId, &app_service_parameters); - ASSERT_FALSE(app_service_parameters.find(kServiceType) == - app_service_parameters.end()); - auto service_names = *(app_service_parameters[kServiceType].service_names); - EXPECT_TRUE(service_names.is_initialized()); - ASSERT_EQ(service_names.size(), 2u); - EXPECT_EQ(static_cast(service_names[0]), "SDL App"); - EXPECT_EQ(static_cast(service_names[1]), "SDL Music"); - - auto handled_rpcs = app_service_parameters[kServiceType].handled_rpcs; - - 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"); + std::shared_ptr snapshot = reps->GenerateSnapshot(); + + auto expected_module_meta = GetDefaultSnapshotModuleMeta(update); + auto& snapshot_module_meta = snapshot->policy_table.module_meta; + EXPECT_EQ(expected_module_meta.toStyledString(), + snapshot_module_meta.ToJsonValue().toStyledString()); } +TEST_F(SQLPTRepresentationTest, + SetMetaInfo_SetSoftwareVersion_ValueIsSetInModuleMeta) { + EXPECT_TRUE(reps->SetMetaInfo(kSoftwareVersion)); + + utils::dbms::SQLQuery query(reps->db()); + const std::string query_select_ccpu = + "SELECT `ccpu_version` FROM `module_meta`"; + + query.Prepare(query_select_ccpu); + query.Next(); + EXPECT_EQ(kSoftwareVersion, query.GetString(0)); +} + +TEST_F(SQLPTRepresentationTest, SetHardwareVersion_ValueIsSetInModuleMeta) { + reps->SetHardwareVersion(kHardwareVersion); + + utils::dbms::SQLQuery query(reps->db()); + const std::string query_select_hardware_version = + "SELECT `hardware_version` FROM `module_meta`"; + + query.Prepare(query_select_hardware_version); + query.Next(); + EXPECT_EQ(kHardwareVersion, query.GetString(0)); +} } // namespace policy_test } // namespace components } // namespace test diff --git a/src/components/protocol/src/bson_object_keys.cc b/src/components/protocol/src/bson_object_keys.cc index acafd3dbd2a..7e1656955f6 100644 --- a/src/components/protocol/src/bson_object_keys.cc +++ b/src/components/protocol/src/bson_object_keys.cc @@ -19,6 +19,12 @@ const char* tcp_ip_address = "tcpIpAddress"; const char* tcp_port = "tcpPort"; const char* reason = "reason"; const char* auth_token = "authToken"; +const char* vehicle_make = "make"; +const char* vehicle_model = "model"; +const char* vehicle_model_year = "modelYear"; +const char* vehicle_trim = "trim"; +const char* vehicle_system_software_version = "systemSoftwareVersion"; +const char* vehicle_system_hardware_version = "systemHardwareVersion"; } // namespace strings 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 33abd4a96b4..02c96fc3c7b 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 @@ -43,6 +43,7 @@ #include "utils/prioritized_queue.h" #include "utils/threads/message_loop_thread.h" +#include "utils/convert_utils.h" #include "utils/custom_string.h" #include "utils/messagemeter.h" #include "utils/semantic_version.h" @@ -213,7 +214,7 @@ class ProtocolHandlerImpl void ProcessFailedPTU() OVERRIDE; -#ifdef EXTERNAL_PROPRIETARY_MODE +#if defined(EXTERNAL_PROPRIETARY_MODE) && defined(ENABLE_SECURITY) /** * @brief ProcessFailedCertDecrypt is called to notify security manager that * certificate decryption failed in the external flow @@ -374,12 +375,15 @@ class ProtocolHandlerImpl * \param protocol_version Version of protocol used for communication * \param service_type Type of session: RPC or BULK Data. RPC by default * \param reason String stating the reason for the rejecting the start service + * \param full_version full protocol version (major.minor.patch) used by the + * mobile proxy */ void SendStartSessionNAck(ConnectionID connection_id, uint8_t session_id, uint8_t protocol_version, uint8_t service_type, - const std::string& reason); + const std::string& reason, + utils::SemanticVersion& full_version); /** * \brief Sends fail of starting session to mobile application @@ -389,13 +393,16 @@ class ProtocolHandlerImpl * \param service_type Type of session: RPC or BULK Data. RPC by default * \param rejected_params List of rejected params to send in payload * \param reason String stating the reason for the rejecting the start service + * \param full_version full protocol version (major.minor.patch) used by the + * mobile proxy */ void SendStartSessionNAck(ConnectionID connection_id, uint8_t session_id, uint8_t protocol_version, uint8_t service_type, std::vector& rejectedParams, - const std::string& reason); + const std::string& reason, + utils::SemanticVersion& full_version); /** * \brief Sends acknowledgement of end session/service to mobile application @@ -455,10 +462,15 @@ class ProtocolHandlerImpl * Only valid when generated_session_id is 0. Note, even if * generated_session_id is 0, the list may be empty. */ + DEPRECATED void NotifySessionStarted(const SessionContext& context, std::vector& rejected_params, const std::string err_reason) OVERRIDE; + void NotifySessionStarted(SessionContext& context, + std::vector& rejected_params, + const std::string err_reason) OVERRIDE; + #ifdef BUILD_TESTS const impl::FromMobileQueue& get_from_mobile_queue() const { return raw_ford_messages_from_mobile_; @@ -674,7 +686,7 @@ class ProtocolHandlerImpl RESULT_CODE HandleControlMessageHeartBeat(const ProtocolPacket& packet); - void PopValideAndExpirateMultiframes(); + void PopValidAndExpiredMultiframes(); // threads::MessageLoopThread<*>::Handler implementations // CALLED ON raw_ford_messages_from_mobile_ thread! @@ -732,6 +744,24 @@ class ProtocolHandlerImpl const uint8_t session_id, const bool protection) const; + /** + * @brief Writes available protocol vehicle data into structured bson + * @param params bson params to write into + * @param data data to write + */ + void WriteProtocolVehicleData( + BsonObject& params, const connection_handler::ProtocolVehicleData& data); + + /** + * \brief Parces full protocol version from start service message headers bson + * \param full_version full protocol version (major.minor.patch) used by the + * mobile proxy + * \param packet Sart service message + * \return true if version successfully parsed, otherwise false + */ + bool ParseFullVersion(utils::SemanticVersion& full_version, + const ProtocolFramePtr& packet) const; + const ProtocolHandlerSettings& settings_; /** diff --git a/src/components/protocol_handler/src/handshake_handler.cc b/src/components/protocol_handler/src/handshake_handler.cc index 4d306fd3304..78f324e0ae1 100644 --- a/src/components/protocol_handler/src/handshake_handler.cc +++ b/src/components/protocol_handler/src/handshake_handler.cc @@ -232,7 +232,8 @@ void HandshakeHandler::ProcessSuccessfulHandshake(const uint32_t connection_key, context_.service_type_, (is_service_already_protected) ? "Service is already protected" - : "Service cannot be protected"); + : "Service cannot be protected", + full_version_); } } @@ -284,7 +285,8 @@ void HandshakeHandler::ProcessFailedHandshake(BsonObject& params, context_.new_session_id_, protocol_version_, context_.service_type_, - reason_msg + (err_reason.empty() ? "" : ": " + err_reason)); + reason_msg + (err_reason.empty() ? "" : ": " + err_reason), + full_version_); } } diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 1db599e6564..525e825d846 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -52,19 +52,13 @@ namespace protocol_handler { SDL_CREATE_LOG_VARIABLE("ProtocolHandler") -/** - * Function return packet data as std::string. - * If packet data is not printable return error message - */ -std::string ConvertPacketDataToString(const uint8_t* data, - const size_t data_size); - const size_t kStackSize = 131072; -const utils::SemanticVersion default_protocol_version(5, 3, 0); +const utils::SemanticVersion default_protocol_version(5, 4, 0); const utils::SemanticVersion min_multiple_transports_version(5, 1, 0); const utils::SemanticVersion min_cloud_app_version(5, 2, 0); const utils::SemanticVersion min_reason_param_version(5, 3, 0); +const utils::SemanticVersion min_vehicle_data_version(5, 4, 0); ProtocolHandlerImpl::ProtocolHandlerImpl( const ProtocolHandlerSettings& settings, @@ -233,6 +227,39 @@ void ProtocolHandlerImpl::SendStartSessionAck( bson_object_deinitialize(&empty_param); } +void ProtocolHandlerImpl::WriteProtocolVehicleData( + BsonObject& params, const connection_handler::ProtocolVehicleData& data) { + auto write_string_to_bson = [¶ms](const std::string& param_name, + const std::string& param_value) { + if (param_value.empty()) { + return; + } + + const uint16_t max_string_length = 500; + char value_buffer[max_string_length + 1]; // extra byte for NULL symbol + strncpy(value_buffer, param_value.c_str(), sizeof(value_buffer)); + value_buffer[max_string_length] = 0; + + if (bson_object_put_string(¶ms, param_name.c_str(), value_buffer)) { + SDL_LOG_DEBUG("Parameter " + << param_name << " has been written to bson with value: " + << bson_object_get_string(¶ms, param_name.c_str())); + } else { + SDL_LOG_DEBUG("Failed to write parameter " << param_name + << " into bson structure"); + } + }; + + write_string_to_bson(strings::vehicle_make, data.vehicle_make); + write_string_to_bson(strings::vehicle_model, data.vehicle_model); + write_string_to_bson(strings::vehicle_model_year, data.vehicle_year); + write_string_to_bson(strings::vehicle_trim, data.vehicle_trim); + write_string_to_bson(strings::vehicle_system_software_version, + data.vehicle_system_software_version); + write_string_to_bson(strings::vehicle_system_hardware_version, + data.vehicle_system_hardware_version); +} + void ProtocolHandlerImpl::SendStartSessionAck( ConnectionID connection_id, uint8_t session_id, @@ -296,6 +323,13 @@ void ProtocolHandlerImpl::SendStartSessionAck( << static_cast(bson_object_get_int64(¶ms, strings::mtu))); if (serviceTypeValue == kRpc) { + SDL_LOG_DEBUG("Collecting protocol vehicle data"); + connection_handler::ProtocolVehicleData data; + if (full_version >= min_vehicle_data_version && + connection_handler_.GetProtocolVehicleData(data)) { + WriteProtocolVehicleData(params, data); + } + // Hash ID is only used in RPC case const bool hash_written = bson_object_put_int32( ¶ms, strings::hash_id, static_cast(hash_id)); @@ -425,6 +459,11 @@ void ProtocolHandlerImpl::SendStartSessionAck( raw_ford_messages_to_mobile_.PostMessage( impl::RawFordMessageToMobile(ptr, false)); + const uint32_t connection_key = + session_observer_.KeyFromPair(connection_id, session_id); + connection_handler_.BindProtocolVersionWithSession(connection_key, + ack_protocol_version); + SDL_LOG_DEBUG("SendStartSessionAck() for connection " << connection_id << " for service_type " << static_cast(service_type) << " session_id " @@ -442,18 +481,21 @@ void ProtocolHandlerImpl::SendStartSessionAck( } } -void ProtocolHandlerImpl::SendStartSessionNAck(ConnectionID connection_id, - uint8_t session_id, - uint8_t protocol_version, - uint8_t service_type, - const std::string& reason) { +void ProtocolHandlerImpl::SendStartSessionNAck( + ConnectionID connection_id, + uint8_t session_id, + uint8_t protocol_version, + uint8_t service_type, + const std::string& reason, + utils::SemanticVersion& full_version) { std::vector rejectedParams; SendStartSessionNAck(connection_id, session_id, protocol_version, service_type, rejectedParams, - reason); + reason, + full_version); } void ProtocolHandlerImpl::SendStartSessionNAck( @@ -462,9 +504,18 @@ void ProtocolHandlerImpl::SendStartSessionNAck( uint8_t protocol_version, uint8_t service_type, std::vector& rejectedParams, - const std::string& reason) { + const std::string& reason, + utils::SemanticVersion& full_version) { SDL_LOG_AUTO_TRACE(); + if (!full_version.isValid()) { + if (!session_observer_.ProtocolVersionUsed( + connection_id, session_id, full_version)) { + SDL_LOG_WARN("Connection: " << connection_id << " and/or session: " + << session_id << "no longer exist(s)."); + } + } + ProtocolFramePtr ptr( new protocol_handler::ProtocolPacket(connection_id, protocol_version, @@ -478,14 +529,6 @@ void ProtocolHandlerImpl::SendStartSessionNAck( uint8_t maxProtocolVersion = SupportedSDLProtocolVersion(); - utils::SemanticVersion full_version; - if (!session_observer_.ProtocolVersionUsed( - connection_id, session_id, full_version)) { - SDL_LOG_WARN("Connection: " << connection_id << " and/or session: " - << session_id << "no longer exist(s)."); - return; - } - if (protocol_version >= PROTOCOL_VERSION_5 && maxProtocolVersion >= PROTOCOL_VERSION_5) { BsonObject payloadObj; @@ -1171,7 +1214,7 @@ void ProtocolHandlerImpl::ProcessFailedPTU() { #endif // ENABLE_SECURITY } -#ifdef EXTERNAL_PROPRIETARY_MODE +#if defined(EXTERNAL_PROPRIETARY_MODE) && defined(ENABLE_SECURITY) void ProtocolHandlerImpl::ProcessFailedCertDecrypt() { SDL_LOG_AUTO_TRACE(); security_manager_->ProcessFailedCertDecrypt(); @@ -1283,7 +1326,7 @@ RESULT_CODE ProtocolHandlerImpl::SendFrame(const ProtocolFramePtr packet) { SDL_LOG_DEBUG( "Packet to be sent: " - << ConvertPacketDataToString(packet->data(), packet->data_size()) + << utils::ConvertBinaryDataToString(packet->data(), packet->data_size()) << " of size: " << packet->data_size()); const RawMessagePtr message_to_send = packet->serializePacket(); if (!message_to_send) { @@ -1379,7 +1422,7 @@ RESULT_CODE ProtocolHandlerImpl::SendMultiFrameMessage( const ProtocolFramePtr firstPacket( new protocol_handler::ProtocolPacket(connection_id, protocol_version, - needs_encryption, + false, FRAME_TYPE_FIRST, service_type, FRAME_DATA_FIRST, @@ -1448,7 +1491,7 @@ RESULT_CODE ProtocolHandlerImpl::HandleSingleFrameMessage( SDL_LOG_DEBUG( "FRAME_TYPE_SINGLE message of size " << packet->data_size() << "; message " - << ConvertPacketDataToString(packet->data(), packet->data_size())); + << utils::ConvertBinaryDataToString(packet->data(), packet->data_size())); // Replace a potential secondary transport ID in the packet with the primary // transport ID @@ -1739,8 +1782,17 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession( reason += " Allowed only in unprotected mode"; } - SendStartSessionNAck( - connection_id, session_id, protocol_version, service_type, reason); + utils::SemanticVersion version; + if (packet->service_type() == kRpc && packet->data() != NULL) { + ParseFullVersion(version, packet); + } + + SendStartSessionNAck(connection_id, + session_id, + protocol_version, + service_type, + reason, + version); return RESULT_OK; } @@ -1816,8 +1868,34 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageRegisterSecondaryTransport( return RESULT_OK; } +bool ProtocolHandlerImpl::ParseFullVersion( + utils::SemanticVersion& full_version, + const ProtocolFramePtr& packet) const { + SDL_LOG_AUTO_TRACE(); + + BsonObject request_params; + size_t request_params_size = bson_object_from_bytes_len( + &request_params, packet->data(), packet->total_data_bytes()); + if (request_params_size > 0) { + char* version_param = + bson_object_get_string(&request_params, strings::protocol_version); + std::string version_string(version_param == NULL ? "" : version_param); + full_version = version_string; + + // Constructed payloads added in Protocol v5 + if (full_version.major_version_ < PROTOCOL_VERSION_5) { + return false; + } + bson_object_deinitialize(&request_params); + } else { + SDL_LOG_WARN("Failed to parse start service packet for version string"); + } + + return true; +} + void ProtocolHandlerImpl::NotifySessionStarted( - const SessionContext& context, + SessionContext& context, std::vector& rejected_params, const std::string err_reason) { SDL_LOG_AUTO_TRACE(); @@ -1837,8 +1915,23 @@ void ProtocolHandlerImpl::NotifySessionStarted( const ServiceType service_type = ServiceTypeFromByte(packet->service_type()); const uint8_t protocol_version = packet->protocol_version(); + utils::SemanticVersion full_version; - if (0 == context.new_session_id_) { + // Can't check protocol_version because the first packet is v1, but there + // could still be a payload, in which case we can get the real protocol + // version + if (packet->service_type() == kRpc && packet->data() != NULL) { + if (ParseFullVersion(full_version, packet)) { + const auto connection_key = session_observer_.KeyFromPair( + packet->connection_id(), context.new_session_id_); + connection_handler_.BindProtocolVersionWithSession(connection_key, + full_version); + } else { + rejected_params.push_back(std::string(strings::protocol_version)); + } + } + + if (context.is_start_session_failed_ || !context.new_session_id_) { SDL_LOG_WARN("Refused by session_observer to create service " << static_cast(service_type) << " type."); const auto session_id = packet->session_id(); @@ -1853,7 +1946,8 @@ void ProtocolHandlerImpl::NotifySessionStarted( protocol_version, packet->service_type(), rejected_params, - err_reason); + err_reason, + full_version); return; } @@ -1903,38 +1997,6 @@ void ProtocolHandlerImpl::NotifySessionStarted( } } - std::shared_ptr fullVersion; - - // Can't check protocol_version because the first packet is v1, but there - // could still be a payload, in which case we can get the real protocol - // version - if (packet->service_type() == kRpc && packet->data() != NULL) { - BsonObject request_params; - size_t request_params_size = bson_object_from_bytes_len( - &request_params, packet->data(), packet->total_data_bytes()); - if (request_params_size > 0) { - char* version_param = - bson_object_get_string(&request_params, strings::protocol_version); - std::string version_string(version_param == NULL ? "" : version_param); - fullVersion = std::make_shared(version_string); - - const auto connection_key = session_observer_.KeyFromPair( - packet->connection_id(), context.new_session_id_); - connection_handler_.BindProtocolVersionWithSession(connection_key, - *fullVersion); - // Constructed payloads added in Protocol v5 - if (fullVersion->major_version_ < PROTOCOL_VERSION_5) { - rejected_params.push_back(std::string(strings::protocol_version)); - } - bson_object_deinitialize(&request_params); - } else { - SDL_LOG_WARN("Failed to parse start service packet for version string"); - fullVersion = std::make_shared(); - } - } else { - fullVersion = std::make_shared(); - } - #ifdef ENABLE_SECURITY // for packet is encrypted and security plugin is enable if (context.is_protected_ && security_manager_) { @@ -1945,7 +2007,7 @@ void ProtocolHandlerImpl::NotifySessionStarted( std::make_shared( *this, session_observer_, - *fullVersion, + full_version, context, packet->protocol_version(), start_session_ack_params, @@ -1971,12 +2033,20 @@ void ProtocolHandlerImpl::NotifySessionStarted( } if (!rejected_params.empty()) { + service_status_update_handler_->OnServiceUpdate( + connection_key, + context.service_type_, + ServiceStatus::SERVICE_START_FAILED); SendStartSessionNAck(context.connection_id_, packet->session_id(), protocol_version, packet->service_type(), rejected_params, - "SSL Handshake failed due to rejected parameters"); + "SSL Handshake failed due to rejected parameters", + full_version); + if (packet->service_type() != kRpc) { + context.is_start_session_failed_ = true; + } } else if (ssl_context->IsInitCompleted()) { // mark service as protected session_observer_.SetProtectionFlag(connection_key, service_type); @@ -1991,7 +2061,7 @@ void ProtocolHandlerImpl::NotifySessionStarted( context.hash_id_, packet->service_type(), PROTECTION_ON, - *fullVersion, + full_version, *start_session_ack_params); } else { SDL_LOG_DEBUG("Adding Handshake handler to listeners: " << handler.get()); @@ -2005,12 +2075,20 @@ void ProtocolHandlerImpl::NotifySessionStarted( if (!security_manager_->IsSystemTimeProviderReady()) { security_manager_->RemoveListener(listener); + service_status_update_handler_->OnServiceUpdate( + connection_key, + context.service_type_, + ServiceStatus::SERVICE_START_FAILED); SendStartSessionNAck(context.connection_id_, packet->session_id(), protocol_version, packet->service_type(), rejected_params, - "System time provider is not ready"); + "System time provider is not ready", + full_version); + if (packet->service_type() != kRpc) { + context.is_start_session_failed_ = true; + } } } } @@ -2031,7 +2109,7 @@ void ProtocolHandlerImpl::NotifySessionStarted( context.hash_id_, packet->service_type(), PROTECTION_OFF, - *fullVersion, + full_version, *start_session_ack_params); } else { service_status_update_handler_->OnServiceUpdate( @@ -2044,23 +2122,40 @@ void ProtocolHandlerImpl::NotifySessionStarted( protocol_version, packet->service_type(), rejected_params, - "Certain parameters in the StartService request were rejected"); + "Certain parameters in the StartService request were rejected", + full_version); + context.is_start_session_failed_ = true; } } +void ProtocolHandlerImpl::NotifySessionStarted( + const SessionContext& context, + std::vector& rejected_params, + const std::string err_reason) { + SessionContext context_copy = context; + NotifySessionStarted(context_copy, rejected_params, err_reason); +} + RESULT_CODE ProtocolHandlerImpl::HandleControlMessageHeartBeat( const ProtocolPacket& packet) { const ConnectionID connection_id = packet.connection_id(); + const uint32_t session_id = packet.session_id(); SDL_LOG_DEBUG("Sending heart beat acknowledgment for connection " - << connection_id); + << connection_id << " session " << session_id); uint8_t protocol_version; if (session_observer_.ProtocolVersionUsed( - connection_id, packet.session_id(), protocol_version)) { + connection_id, session_id, protocol_version)) { // TODO(EZamakhov): investigate message_id for HeartBeatAck if (protocol_version >= PROTOCOL_VERSION_3 && protocol_version <= PROTOCOL_VERSION_5) { - return SendHeartBeatAck( - connection_id, packet.session_id(), packet.message_id()); + const uint32_t connection_key = + session_observer_.KeyFromPair(connection_id, session_id); + if (!connection_handler_.IsSessionHeartbeatTracked(connection_key)) { + SDL_LOG_DEBUG("Session heartbeat tracking is not started. " + << "Starting it for session " << session_id); + connection_handler_.StartSessionHeartBeat(connection_key); + } + return SendHeartBeatAck(connection_id, session_id, packet.message_id()); } else { SDL_LOG_WARN("HeartBeat is not supported"); return RESULT_HEARTBEAT_IS_NOT_SUPPORTED; @@ -2073,7 +2168,7 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageHeartBeat( } } -void ProtocolHandlerImpl::PopValideAndExpirateMultiframes() { +void ProtocolHandlerImpl::PopValidAndExpiredMultiframes() { SDL_LOG_AUTO_TRACE(); const ProtocolFramePtrList& frame_list = multiframe_builder_.PopMultiframes(); for (ProtocolFramePtrList::const_iterator it = frame_list.begin(); @@ -2180,7 +2275,7 @@ void ProtocolHandlerImpl::Handle(const impl::RawFordMessageFromMobile message) { FRAME_TYPE_FIRST == message->frame_type()) { SDL_LOG_DEBUG("Packet: dataSize " << message->data_size()); HandleMessage(message); - PopValideAndExpirateMultiframes(); + PopValidAndExpiredMultiframes(); } else { SDL_LOG_WARN("handleMessagesFromMobileApp() - incorrect or NULL data"); } @@ -2396,24 +2491,6 @@ void ProtocolHandlerImpl::SetTelemetryObserver(PHTelemetryObserver* observer) { } #endif // TELEMETRY_MONITOR -std::string ConvertPacketDataToString(const uint8_t* data, - const size_t data_size) { - if (0 == data_size) - return std::string(); - bool is_printable_array = true; - std::locale loc; - const char* text = reinterpret_cast(data); - // Check data for printability - for (size_t i = 0; i < data_size; ++i) { - if (!std::isprint(text[i], loc)) { - is_printable_array = false; - break; - } - } - return is_printable_array ? std::string(text, data_size) - : std::string("is raw data"); -} - uint8_t ProtocolHandlerImpl::SupportedSDLProtocolVersion() const { SDL_LOG_AUTO_TRACE(); return get_settings().max_supported_protocol_version(); diff --git a/src/components/protocol_handler/test/include/protocol_handler/mock_telemetry_observer.h b/src/components/protocol_handler/test/include/protocol_handler/mock_telemetry_observer.h index 9a91a5d1f7b..f303e8ed571 100644 --- a/src/components/protocol_handler/test/include/protocol_handler/mock_telemetry_observer.h +++ b/src/components/protocol_handler/test/include/protocol_handler/mock_telemetry_observer.h @@ -34,8 +34,7 @@ #define SRC_COMPONENTS_PROTOCOL_HANDLER_TEST_INCLUDE_PROTOCOL_HANDLER_MOCK_TELEMETRY_OBSERVER_H_ #include "gmock/gmock.h" -#include "protocol_handler/time_metric_observer.h" -#include "utils/shared_ptr.h" +#include "protocol_handler/telemetry_observer.h" namespace test { namespace components { @@ -44,8 +43,9 @@ namespace protocol_handler_test { class MockPHTelemetryObserver : public ::protocol_handler::PHTelemetryObserver { public: MOCK_METHOD2(StartMessageProcess, - void(uint32_t, const date_time::TimeDuration&)); - MOCK_METHOD2(EndMessageProcess, void(std::shared_ptr)); + void(uint32_t message_id, + const date_time::TimeDuration& start_time)); + MOCK_METHOD1(EndMessageProcess, void(std::shared_ptr m)); }; } // namespace protocol_handler_test 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 41c16817b5f..ae5b7fb1ae9 100644 --- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc +++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc @@ -41,11 +41,14 @@ #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/mock_telemetry_observer.h" #include "protocol_handler/protocol_handler.h" #include "protocol_handler/protocol_handler_impl.h" #ifdef ENABLE_SECURITY #include "security_manager/mock_security_manager.h" #include "security_manager/mock_ssl_context.h" +#else +#include "utils/byte_order.h" #endif // ENABLE_SECURITY #include "transport_manager/mock_transport_manager.h" #include "utils/mock_system_time_handler.h" @@ -130,6 +133,7 @@ using ::testing::AnyOf; using ::testing::AtLeast; using ::testing::ByRef; using ::testing::DoAll; +using ::testing::ElementsAreArray; using ::testing::Eq; using ::testing::Invoke; using ::testing::Return; @@ -137,6 +141,7 @@ using ::testing::ReturnNull; using ::testing::ReturnRef; using ::testing::ReturnRefOfCopy; using ::testing::SaveArg; +using ::testing::SaveArgPointee; using ::testing::SetArgPointee; using ::testing::SetArgReferee; @@ -151,6 +156,10 @@ ACTION_P5(InvokeMemberFuncWithArg3, ptr, memberFunc, a, b, c) { } namespace { +const bool kFinalMessage = true; +const uint8_t* const null_data_ = NULL; +const uint32_t kInvalidSessionId = 0u; +const uint32_t kValidSessionId = 1u; const uint32_t kAsyncExpectationsTimeout = 10000u; const uint32_t kMicrosecondsInMillisecond = 1000u; const uint32_t kAddSessionWaitTimeMs = 100u; @@ -233,6 +242,7 @@ class ProtocolHandlerImplTest : public ::testing::Test { const_cast( protocol_handler_impl->get_to_mobile_queue()) .WaitDumpQueue(); + protocol_handler_impl->Stop(); } // Emulate connection establish @@ -263,7 +273,7 @@ class ProtocolHandlerImplTest : public ::testing::Test { void AddSession(const std::shared_ptr& waiter, uint32_t& times) { using namespace protocol_handler; - ASSERT_TRUE(NULL != waiter.get()); + ASSERT_TRUE(NULL != waiter); AddConnection(); const ServiceType start_service = kRpc; @@ -277,7 +287,7 @@ class ProtocolHandlerImplTest : public ::testing::Test { const bool callback_protection_flag = PROTECTION_OFF; #endif // ENABLE_SECURITY - const protocol_handler::SessionContext context = + protocol_handler::SessionContext context = GetSessionContext(connection_id, NEW_SESSION_ID, session_id, @@ -311,11 +321,15 @@ class ProtocolHandlerImplTest : public ::testing::Test { // Return sessions start success WillOnce(DoAll( NotifyTestAsyncWaiter(waiter), - InvokeMemberFuncWithArg3(protocol_handler_impl.get(), - &ProtocolHandler::NotifySessionStarted, - context, - ByRef(empty_rejected_param_), - std::string()))); + InvokeMemberFuncWithArg3( + protocol_handler_impl.get(), + static_cast&, + const std::string)>( + &ProtocolHandler::NotifySessionStarted), + ByRef(context), + ByRef(empty_rejected_param_), + std::string()))); times++; // Expect send Ack with PROTECTION_OFF (on no Security Manager) @@ -388,6 +402,61 @@ class ProtocolHandlerImplTest : public ::testing::Test { data); } + void OnTMMessageSend() { + const uint8_t data_size = 0u; + ProtocolFramePtr protocol_packet = + std::make_shared(connection_id, + PROTOCOL_VERSION_3, + PROTECTION_OFF, + FRAME_TYPE_SINGLE, + kRpc, + FRAME_DATA_SINGLE, + session_id, + data_size, + message_id, + null_data_); + + RawMessagePtr message = protocol_packet->serializePacket(); + EXPECT_CALL(session_observer_mock, + PairFromKey(message->connection_key(), _, _)) + .WillOnce(DoAll(SetArgPointee<1>(connection_id), + SetArgPointee<2>(session_id))); + + protocol_handler::impl::RawFordMessageToMobile raw_message_to_mobile( + protocol_packet, kFinalMessage); + protocol_handler::impl::ToMobileQueue::Handler* + raw_message_to_mobile_handler = protocol_handler_impl.get(); + raw_message_to_mobile_handler->Handle(raw_message_to_mobile); + + MockProtocolObserver mock_protocol_observer; + protocol_handler_impl->AddProtocolObserver(&mock_protocol_observer); + EXPECT_CALL(mock_protocol_observer, OnMobileMessageSent(_)); + + EXPECT_CALL(session_observer_mock, + ProtocolVersionUsed(_, _, An())) + .WillOnce(Return(false)); + + tm_listener->OnTMMessageSend(message); + } + + ProtocolFramePtr CreateFramePtrWithData(const uint8_t data_value, + const uint8_t frame_type) { + const uint8_t data_size = 1u; + ProtocolFramePtr frame_ptr = + std::make_shared(connection_id, + PROTOCOL_VERSION_3, + PROTECTION_OFF, + frame_type, + kAudio, + FRAME_DATA_END_SERVICE_ACK, + session_id, + data_size, + message_id, + &data_value); + + return frame_ptr; + } + void VerifySecondaryTransportParamsInStartSessionAck( bool config_multiple_transports_enabled, const std::vector& config_secondary_transports_for_usb, @@ -423,6 +492,10 @@ class ProtocolHandlerImplTest : public ::testing::Test { transport_manager_mock; testing::StrictMock session_observer_mock; + testing::StrictMock + protocol_observer_mock; + testing::StrictMock + telemetry_observer_mock; #ifdef ENABLE_SECURITY testing::NiceMock security_manager_mock; @@ -453,12 +526,6 @@ class OnHandshakeDoneFunctor { }; #endif // ENABLE_SECURITY -/* - * ProtocolHandler shall skip empty message - */ -TEST_F(ProtocolHandlerImplTest, RecieveEmptyRawMessage) { - tm_listener->OnTMMessageReceived(RawMessagePtr()); -} /* * ProtocolHandler shall disconnect on no connection */ @@ -486,7 +553,7 @@ TEST_F(ProtocolHandlerImplTest, const int call_times = 5; AddConnection(); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; ServiceType service_type; // Expect verification of allowed transport @@ -507,6 +574,14 @@ TEST_F(ProtocolHandlerImplTest, .Times(call_times) .WillRepeatedly(ReturnRef(video_service_transports)); + protocol_handler::SessionContext context = + GetSessionContext(connection_id, + NEW_SESSION_ID, + SESSION_START_REJECT, + service_type, + HASH_ID_WRONG, + PROTECTION_OFF); + // Expect ConnectionHandler check EXPECT_CALL( session_observer_mock, @@ -518,19 +593,18 @@ TEST_F(ProtocolHandlerImplTest, .Times(call_times) . // Return sessions start rejection - WillRepeatedly( - DoAll(NotifyTestAsyncWaiter(&waiter), - SaveArg<2>(&service_type), - InvokeMemberFuncWithArg3(protocol_handler_impl.get(), - &ProtocolHandler::NotifySessionStarted, - GetSessionContext(connection_id, - NEW_SESSION_ID, - SESSION_START_REJECT, - service_type, - HASH_ID_WRONG, - PROTECTION_OFF), - ByRef(empty_rejected_param_), - std::string()))); + WillRepeatedly(DoAll( + NotifyTestAsyncWaiter(waiter), + SaveArg<2>(&service_type), + InvokeMemberFuncWithArg3( + protocol_handler_impl.get(), + static_cast&, + const std::string)>( + &ProtocolHandler::NotifySessionStarted), + ByRef(context), + ByRef(empty_rejected_param_), + std::string()))); times += call_times; // Expect send NAck @@ -543,7 +617,7 @@ TEST_F(ProtocolHandlerImplTest, SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_NACK, PROTECTION_OFF))) .Times(call_times) - .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times += call_times; SendControlMessage( @@ -557,7 +631,7 @@ TEST_F(ProtocolHandlerImplTest, SendControlMessage( PROTECTION_OFF, kBulk, NEW_SESSION_ID, FRAME_DATA_START_SERVICE); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } /* * ProtocolHandler shall send NAck on session_observer rejection @@ -578,7 +652,7 @@ TEST_F(ProtocolHandlerImplTest, StartSession_Protected_SessionObserverReject) { const bool callback_protection_flag = PROTECTION_OFF; #endif // ENABLE_SECURITY - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; ServiceType service_type; // Expect verification of allowed transport @@ -599,6 +673,14 @@ TEST_F(ProtocolHandlerImplTest, StartSession_Protected_SessionObserverReject) { .Times(call_times) .WillRepeatedly(ReturnRef(video_service_transports)); + protocol_handler::SessionContext context = + GetSessionContext(connection_id, + NEW_SESSION_ID, + SESSION_START_REJECT, + service_type, + HASH_ID_WRONG, + callback_protection_flag); + // Expect ConnectionHandler check EXPECT_CALL( session_observer_mock, @@ -611,18 +693,17 @@ TEST_F(ProtocolHandlerImplTest, StartSession_Protected_SessionObserverReject) { . // Return sessions start rejection WillRepeatedly(DoAll( - NotifyTestAsyncWaiter(&waiter), + NotifyTestAsyncWaiter(waiter), SaveArg<2>(&service_type), - InvokeMemberFuncWithArg3(protocol_handler_impl.get(), - &ProtocolHandler::NotifySessionStarted, - GetSessionContext(connection_id, - NEW_SESSION_ID, - SESSION_START_REJECT, - service_type, - HASH_ID_WRONG, - callback_protection_flag), - ByRef(empty_rejected_param_), - std::string()))); + InvokeMemberFuncWithArg3( + protocol_handler_impl.get(), + static_cast&, + const std::string)>( + &ProtocolHandler::NotifySessionStarted), + ByRef(context), + ByRef(empty_rejected_param_), + std::string()))); times += call_times; // Expect send NAck with encryption OFF @@ -635,7 +716,7 @@ TEST_F(ProtocolHandlerImplTest, StartSession_Protected_SessionObserverReject) { SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_NACK, PROTECTION_OFF))) .Times(call_times) - .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times += call_times; SendControlMessage( @@ -649,7 +730,7 @@ TEST_F(ProtocolHandlerImplTest, StartSession_Protected_SessionObserverReject) { SendControlMessage( PROTECTION_ON, kBulk, NEW_SESSION_ID, FRAME_DATA_START_SERVICE); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } /* * ProtocolHandler shall send Ack on session_observer accept @@ -661,7 +742,7 @@ TEST_F(ProtocolHandlerImplTest, AddConnection(); const ServiceType start_service = kRpc; - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; // Expect verification of allowed transport EXPECT_CALL(session_observer_mock, @@ -678,6 +759,13 @@ TEST_F(ProtocolHandlerImplTest, EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) .WillOnce(ReturnRef(video_service_transports)); + protocol_handler::SessionContext context = GetSessionContext(connection_id, + NEW_SESSION_ID, + session_id, + start_service, + HASH_ID_WRONG, + PROTECTION_OFF); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -687,18 +775,17 @@ TEST_F(ProtocolHandlerImplTest, An())) . // Return sessions start success - WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), - InvokeMemberFuncWithArg3(protocol_handler_impl.get(), - &ProtocolHandler::NotifySessionStarted, - GetSessionContext(connection_id, - NEW_SESSION_ID, - session_id, - start_service, - HASH_ID_WRONG, - PROTECTION_OFF), - ByRef(empty_rejected_param_), - std::string()))); + WillOnce(DoAll( + NotifyTestAsyncWaiter(waiter), + InvokeMemberFuncWithArg3( + protocol_handler_impl.get(), + static_cast&, + const std::string)>( + &ProtocolHandler::NotifySessionStarted), + ByRef(context), + ByRef(empty_rejected_param_), + std::string()))); times++; SetProtocolVersion2(); @@ -706,13 +793,13 @@ TEST_F(ProtocolHandlerImplTest, EXPECT_CALL(transport_manager_mock, SendMessageToDevice( ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_OFF))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; SendControlMessage( PROTECTION_OFF, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } /* * ProtocolHandler shall send Ack on session_observer accept @@ -723,7 +810,7 @@ TEST_F(ProtocolHandlerImplTest, TEST_F(ProtocolHandlerImplTest, StartSession_Protected_SessionObserverAccept) { SetProtocolVersion2(); - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); @@ -791,7 +878,7 @@ TEST_F(ProtocolHandlerImplTest, std::string("BTMAC")), connection_id2); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; // Expect verification of allowed transport @@ -834,7 +921,7 @@ TEST_F(ProtocolHandlerImplTest, An())) // don't call NotifySessionStartedContext() immediately, instead call it // after second OnSessionStartedCallback() - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; BsonObject bson_params2; @@ -853,6 +940,22 @@ TEST_F(ProtocolHandlerImplTest, EXPECT_CALL(session_observer_mock, ProtocolVersionUsed(_, _, An())) .WillOnce(Return(true)); + + protocol_handler::SessionContext rejected_context = + GetSessionContext(connection_id2, + session_id2, + SESSION_START_REJECT, + start_service, + HASH_ID_WRONG, + PROTECTION_OFF); + + protocol_handler::SessionContext context = + GetSessionContext(connection_id1, + session_id1, + generated_session_id1, + start_service, + HASH_ID_WRONG, + PROTECTION_OFF); EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id2, session_id2, @@ -860,27 +963,25 @@ TEST_F(ProtocolHandlerImplTest, PROTECTION_OFF, An())) .WillOnce(DoAll( - NotifyTestAsyncWaiter(&waiter), - InvokeMemberFuncWithArg3(protocol_handler_impl.get(), - &ProtocolHandler::NotifySessionStarted, - GetSessionContext(connection_id2, - session_id2, - SESSION_START_REJECT, - start_service, - HASH_ID_WRONG, - PROTECTION_OFF), - ByRef(rejected_param_list), - std::string()), - InvokeMemberFuncWithArg3(protocol_handler_impl.get(), - &ProtocolHandler::NotifySessionStarted, - GetSessionContext(connection_id1, - session_id1, - generated_session_id1, - start_service, - HASH_ID_WRONG, - PROTECTION_OFF), - ByRef(empty_rejected_param_), - std::string()))); + NotifyTestAsyncWaiter(waiter), + InvokeMemberFuncWithArg3( + protocol_handler_impl.get(), + static_cast&, + const std::string)>( + &ProtocolHandler::NotifySessionStarted), + ByRef(rejected_context), + ByRef(rejected_param_list), + std::string()), + InvokeMemberFuncWithArg3( + protocol_handler_impl.get(), + static_cast&, + const std::string)>( + &ProtocolHandler::NotifySessionStarted), + ByRef(context), + ByRef(empty_rejected_param_), + std::string()))); times++; BsonObject bson_ack_params; @@ -902,7 +1003,7 @@ TEST_F(ProtocolHandlerImplTest, PROTECTION_OFF, connection_id1, Eq(ack_params)))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; BsonArray bson_arr; @@ -924,7 +1025,7 @@ TEST_F(ProtocolHandlerImplTest, PROTECTION_OFF, connection_id2, Eq(nack_params)))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; SendTMMessage(connection_id1, @@ -949,7 +1050,7 @@ TEST_F(ProtocolHandlerImplTest, message_id, params2.size() > 0 ? ¶ms2[0] : NULL); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); bson_object_deinitialize(&bson_params1); bson_object_deinitialize(&bson_params2); @@ -964,7 +1065,7 @@ TEST_F(ProtocolHandlerImplTest, StartSession_Audio_RejectByTransportType) { AddConnection(); const ServiceType start_service = kAudio; - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; // Expect verification of allowed transport EXPECT_CALL(session_observer_mock, @@ -988,13 +1089,13 @@ TEST_F(ProtocolHandlerImplTest, StartSession_Audio_RejectByTransportType) { EXPECT_CALL(transport_manager_mock, SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_NACK, PROTECTION_OFF))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; SendControlMessage( PROTECTION_OFF, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } /* @@ -1006,7 +1107,7 @@ TEST_F(ProtocolHandlerImplTest, StartSession_Video_RejectByTransportType) { AddConnection(); const ServiceType start_service = kMobileNav; - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; // Expect verification of allowed transport EXPECT_CALL(session_observer_mock, @@ -1031,13 +1132,13 @@ TEST_F(ProtocolHandlerImplTest, StartSession_Video_RejectByTransportType) { EXPECT_CALL(transport_manager_mock, SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_NACK, PROTECTION_OFF))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; SendControlMessage( PROTECTION_OFF, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } // TODO(EZamakhov): add test for get_hash_id/set_hash_id from @@ -1046,7 +1147,7 @@ TEST_F(ProtocolHandlerImplTest, StartSession_Video_RejectByTransportType) { * ProtocolHandler shall send NAck on session_observer rejection */ TEST_F(ProtocolHandlerImplTest, EndSession_SessionObserverReject) { - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); @@ -1086,7 +1187,7 @@ TEST_F(ProtocolHandlerImplTest, EndSession_SessionObserverReject) { * ProtocolHandler shall send NAck on wrong hash code */ TEST_F(ProtocolHandlerImplTest, EndSession_Success) { - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); @@ -1122,7 +1223,7 @@ TEST_F(ProtocolHandlerImplTest, EndSession_Success) { #ifdef ENABLE_SECURITY TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtocoloV1) { using namespace protocol_handler; - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); @@ -1145,6 +1246,12 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtocoloV1) { EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) .WillOnce(ReturnRef(video_service_transports)); + protocol_handler::SessionContext context = GetSessionContext(connection_id, + NEW_SESSION_ID, + session_id, + start_service, + HASH_ID_WRONG, + PROTECTION_OFF); // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1154,18 +1261,17 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtocoloV1) { An())) . // Return sessions start success - WillOnce( - DoAll(NotifyTestAsyncWaiter(waiter), - InvokeMemberFuncWithArg3(protocol_handler_impl.get(), - &ProtocolHandler::NotifySessionStarted, - GetSessionContext(connection_id, - NEW_SESSION_ID, - session_id, - start_service, - HASH_ID_WRONG, - PROTECTION_OFF), - ByRef(empty_rejected_param_), - std::string()))); + WillOnce(DoAll( + NotifyTestAsyncWaiter(waiter), + InvokeMemberFuncWithArg3( + protocol_handler_impl.get(), + static_cast&, + const std::string)>( + &ProtocolHandler::NotifySessionStarted), + ByRef(context), + ByRef(empty_rejected_param_), + std::string()))); times++; SetProtocolVersion2(); @@ -1200,7 +1306,7 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionUnprotected) { AddSecurityManager(); const ServiceType start_service = kRpc; - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; // Expect verification of allowed transport EXPECT_CALL(session_observer_mock, @@ -1217,6 +1323,13 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionUnprotected) { EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) .WillOnce(ReturnRef(video_service_transports)); + protocol_handler::SessionContext context = GetSessionContext(connection_id, + NEW_SESSION_ID, + session_id, + start_service, + HASH_ID_WRONG, + PROTECTION_OFF); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1226,18 +1339,17 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionUnprotected) { An())) . // Return sessions start success - WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), - InvokeMemberFuncWithArg3(protocol_handler_impl.get(), - &ProtocolHandler::NotifySessionStarted, - GetSessionContext(connection_id, - NEW_SESSION_ID, - session_id, - start_service, - HASH_ID_WRONG, - PROTECTION_OFF), - ByRef(empty_rejected_param_), - std::string()))); + WillOnce(DoAll( + NotifyTestAsyncWaiter(waiter), + InvokeMemberFuncWithArg3( + protocol_handler_impl.get(), + static_cast&, + const std::string)>( + &ProtocolHandler::NotifySessionStarted), + ByRef(context), + ByRef(empty_rejected_param_), + std::string()))); times++; SetProtocolVersion2(); @@ -1245,13 +1357,13 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionUnprotected) { EXPECT_CALL(transport_manager_mock, SendMessageToDevice( ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_OFF))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; SendControlMessage( PROTECTION_OFF, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } /* * ProtocolHandler shall send Ack with PROTECTION_OFF on fail SLL creation @@ -1262,7 +1374,7 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtected_Fail) { AddSecurityManager(); const ServiceType start_service = kRpc; - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; protocol_handler::SessionContext context = GetSessionContext(connection_id, @@ -1271,6 +1383,7 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtected_Fail) { start_service, HASH_ID_WRONG, PROTECTION_ON); + context.is_new_service_ = true; // Expect verification of allowed transport @@ -1297,13 +1410,17 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtected_Fail) { An())) . // Return sessions start success - WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), - InvokeMemberFuncWithArg3(protocol_handler_impl.get(), - &ProtocolHandler::NotifySessionStarted, - context, - ByRef(empty_rejected_param_), - std::string()))); + WillOnce(DoAll( + NotifyTestAsyncWaiter(waiter), + InvokeMemberFuncWithArg3( + protocol_handler_impl.get(), + static_cast&, + const std::string)>( + &ProtocolHandler::NotifySessionStarted), + ByRef(context), + ByRef(empty_rejected_param_), + std::string()))); times++; SetProtocolVersion2(); @@ -1314,20 +1431,20 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtected_Fail) { ContextCreationStrategy::kUseExisting)) . // Return fail protection - WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), ReturnNull())); + WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), ReturnNull())); times++; // Expect send Ack with PROTECTION_OFF (on fail SLL creation) EXPECT_CALL(transport_manager_mock, SendMessageToDevice( ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_OFF))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; SendControlMessage( PROTECTION_ON, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } /* * ProtocolHandler shall send Ack with PROTECTION_ON on already established and @@ -1340,7 +1457,7 @@ TEST_F(ProtocolHandlerImplTest, AddSecurityManager(); const ServiceType start_service = kRpc; - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; // Expect verification of allowed transport EXPECT_CALL(session_observer_mock, @@ -1357,6 +1474,13 @@ TEST_F(ProtocolHandlerImplTest, EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) .WillOnce(ReturnRef(video_service_transports)); + protocol_handler::SessionContext context = GetSessionContext(connection_id, + NEW_SESSION_ID, + session_id, + start_service, + HASH_ID_WRONG, + PROTECTION_ON); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1366,18 +1490,17 @@ TEST_F(ProtocolHandlerImplTest, An())) . // Return sessions start success - WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), - InvokeMemberFuncWithArg3(protocol_handler_impl.get(), - &ProtocolHandler::NotifySessionStarted, - GetSessionContext(connection_id, - NEW_SESSION_ID, - session_id, - start_service, - HASH_ID_WRONG, - PROTECTION_ON), - ByRef(empty_rejected_param_), - std::string()))); + WillOnce(DoAll( + NotifyTestAsyncWaiter(waiter), + InvokeMemberFuncWithArg3( + protocol_handler_impl.get(), + static_cast&, + const std::string)>( + &ProtocolHandler::NotifySessionStarted), + ByRef(context), + ByRef(empty_rejected_param_), + std::string()))); times++; SetProtocolVersion2(); @@ -1385,34 +1508,33 @@ TEST_F(ProtocolHandlerImplTest, EXPECT_CALL(security_manager_mock, CreateSSLContext(connection_key, _)) . // Return new SSLContext - WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), Return(&ssl_context_mock))); + WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(&ssl_context_mock))); times++; // Initilization check EXPECT_CALL(ssl_context_mock, IsInitCompleted()) . // emulate SSL is initilized - WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(true))); + WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); times++; // Expect service protection enable EXPECT_CALL(session_observer_mock, SetProtectionFlag(connection_key, start_service)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; // Expect send Ack with PROTECTION_ON (on SSL is initilized) EXPECT_CALL(transport_manager_mock, SendMessageToDevice( ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_ON))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; SendControlMessage( PROTECTION_ON, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } /* * ProtocolHandler shall send Ack with PROTECTION_OFF on session handshhake fail @@ -1424,7 +1546,7 @@ TEST_F(ProtocolHandlerImplTest, AddSecurityManager(); const ServiceType start_service = kRpc; - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; protocol_handler::SessionContext context = GetSessionContext(connection_id, NEW_SESSION_ID, @@ -1458,13 +1580,17 @@ TEST_F(ProtocolHandlerImplTest, An())) . // Return sessions start success - WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), - InvokeMemberFuncWithArg3(protocol_handler_impl.get(), - &ProtocolHandler::NotifySessionStarted, - context, - ByRef(empty_rejected_param_), - std::string()))); + WillOnce(DoAll( + NotifyTestAsyncWaiter(waiter), + InvokeMemberFuncWithArg3( + protocol_handler_impl.get(), + static_cast&, + const std::string)>( + &ProtocolHandler::NotifySessionStarted), + ByRef(context), + ByRef(empty_rejected_param_), + std::string()))); times++; std::vector services; @@ -1484,14 +1610,14 @@ TEST_F(ProtocolHandlerImplTest, EXPECT_CALL(ssl_context_mock, IsInitCompleted()) . // emulate SSL is not initilized - WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(false))); + WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(false))); times++; // Pending handshake check EXPECT_CALL(ssl_context_mock, IsHandshakePending()) . // emulate is pending - WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(true))); + WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); times++; // Expect add listener for handshake result @@ -1505,13 +1631,13 @@ TEST_F(ProtocolHandlerImplTest, EXPECT_CALL(transport_manager_mock, SendMessageToDevice( ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_OFF))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; SendControlMessage( PROTECTION_ON, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } /* * ProtocolHandler shall send Ack with PROTECTION_ON on session handshhake @@ -1529,7 +1655,7 @@ TEST_F(ProtocolHandlerImplTest, ON_CALL(protocol_handler_settings_mock, force_protected_service()) .WillByDefault(ReturnRefOfCopy(services)); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; // Expect verification of allowed transport EXPECT_CALL(session_observer_mock, @@ -1546,6 +1672,13 @@ TEST_F(ProtocolHandlerImplTest, EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) .WillOnce(ReturnRef(video_service_transports)); + protocol_handler::SessionContext context = GetSessionContext(connection_id, + NEW_SESSION_ID, + session_id, + start_service, + HASH_ID_WRONG, + PROTECTION_ON); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1555,47 +1688,45 @@ TEST_F(ProtocolHandlerImplTest, An())) . // Return sessions start success - WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), - InvokeMemberFuncWithArg3(protocol_handler_impl.get(), - &ProtocolHandler::NotifySessionStarted, - GetSessionContext(connection_id, - NEW_SESSION_ID, - session_id, - start_service, - HASH_ID_WRONG, - PROTECTION_ON), - ByRef(empty_rejected_param_), - std::string()))); + WillOnce(DoAll( + NotifyTestAsyncWaiter(waiter), + InvokeMemberFuncWithArg3( + protocol_handler_impl.get(), + static_cast&, + const std::string)>( + &ProtocolHandler::NotifySessionStarted), + ByRef(context), + ByRef(empty_rejected_param_), + std::string()))); times++; // call new SSLContext creation EXPECT_CALL(security_manager_mock, CreateSSLContext(connection_key, _)) . // Return new SSLContext - WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), Return(&ssl_context_mock))); + WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(&ssl_context_mock))); times++; // Initilization check EXPECT_CALL(ssl_context_mock, IsInitCompleted()) . // emulate SSL is not initilized - WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(false))); + WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(false))); times++; // Pending handshake check EXPECT_CALL(ssl_context_mock, IsHandshakePending()) . // emulate is pending - WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(true))); + WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); times++; // Expect add listener for handshake result EXPECT_CALL(security_manager_mock, AddListener(_)) // Emulate handshake fail .WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), + DoAll(NotifyTestAsyncWaiter(waiter), Invoke(OnHandshakeDoneFunctor( connection_key, security_manager::SSLContext::Handshake_Result_Success)))); @@ -1606,26 +1737,26 @@ TEST_F(ProtocolHandlerImplTest, GetSSLContext(connection_key, start_service)) . // Emulate protection for service is not enabled - WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), ReturnNull())); + WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), ReturnNull())); times++; // Expect service protection enable EXPECT_CALL(session_observer_mock, SetProtectionFlag(connection_key, start_service)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; // Expect send Ack with PROTECTION_OFF (on fail handshake) EXPECT_CALL(transport_manager_mock, SendMessageToDevice( ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_ON))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; SendControlMessage( PROTECTION_ON, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } /* * ProtocolHandler shall send Ack with PROTECTION_ON on session handshhake @@ -1643,7 +1774,7 @@ TEST_F( ON_CALL(protocol_handler_settings_mock, force_protected_service()) .WillByDefault(ReturnRefOfCopy(services)); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; // Expect verification of allowed transport EXPECT_CALL(session_observer_mock, @@ -1660,6 +1791,13 @@ TEST_F( EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) .WillOnce(ReturnRef(video_service_transports)); + protocol_handler::SessionContext context = GetSessionContext(connection_id, + NEW_SESSION_ID, + session_id, + start_service, + HASH_ID_WRONG, + PROTECTION_ON); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1669,26 +1807,24 @@ TEST_F( An())) . // Return sessions start success - WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), - InvokeMemberFuncWithArg3(protocol_handler_impl.get(), - &ProtocolHandler::NotifySessionStarted, - GetSessionContext(connection_id, - NEW_SESSION_ID, - session_id, - start_service, - HASH_ID_WRONG, - PROTECTION_ON), - ByRef(empty_rejected_param_), - std::string()))); + WillOnce(DoAll( + NotifyTestAsyncWaiter(waiter), + InvokeMemberFuncWithArg3( + protocol_handler_impl.get(), + static_cast&, + const std::string)>( + &ProtocolHandler::NotifySessionStarted), + ByRef(context), + ByRef(empty_rejected_param_), + std::string()))); times++; // call new SSLContext creation EXPECT_CALL(security_manager_mock, CreateSSLContext(connection_key, _)) . // Return new SSLContext - WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), Return(&ssl_context_mock))); + WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(&ssl_context_mock))); times++; // Initilization check @@ -1701,14 +1837,14 @@ TEST_F( EXPECT_CALL(ssl_context_mock, IsHandshakePending()) . // emulate is pending - WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(true))); + WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); times++; // Expect add listener for handshake result EXPECT_CALL(security_manager_mock, AddListener(_)) // Emulate handshake fail .WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), + DoAll(NotifyTestAsyncWaiter(waiter), Invoke(OnHandshakeDoneFunctor( connection_key, security_manager::SSLContext::Handshake_Result_Success)))); @@ -1719,26 +1855,26 @@ TEST_F( GetSSLContext(connection_key, start_service)) . // Emulate protection for service is not enabled - WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), ReturnNull())); + WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), ReturnNull())); times++; // Expect service protection enable EXPECT_CALL(session_observer_mock, SetProtectionFlag(connection_key, start_service)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; // Expect send Ack with PROTECTION_OFF (on fail handshake) EXPECT_CALL(transport_manager_mock, SendMessageToDevice( ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_ON))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; SendControlMessage( PROTECTION_ON, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } /* * ProtocolHandler shall send Ack with PROTECTION_ON on session handshhake @@ -1755,7 +1891,7 @@ TEST_F(ProtocolHandlerImplTest, ON_CALL(protocol_handler_settings_mock, force_protected_service()) .WillByDefault(ReturnRefOfCopy(services)); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; // Expect verification of allowed transport EXPECT_CALL(session_observer_mock, @@ -1772,6 +1908,13 @@ TEST_F(ProtocolHandlerImplTest, EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) .WillOnce(ReturnRef(video_service_transports)); + protocol_handler::SessionContext context = GetSessionContext(connection_id, + NEW_SESSION_ID, + session_id, + start_service, + HASH_ID_WRONG, + PROTECTION_ON); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1781,18 +1924,17 @@ TEST_F(ProtocolHandlerImplTest, An())) . // Return sessions start success - WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), - InvokeMemberFuncWithArg3(protocol_handler_impl.get(), - &ProtocolHandler::NotifySessionStarted, - GetSessionContext(connection_id, - NEW_SESSION_ID, - session_id, - start_service, - HASH_ID_WRONG, - PROTECTION_ON), - ByRef(empty_rejected_param_), - std::string()))); + WillOnce(DoAll( + NotifyTestAsyncWaiter(waiter), + InvokeMemberFuncWithArg3( + protocol_handler_impl.get(), + static_cast&, + const std::string)>( + &ProtocolHandler::NotifySessionStarted), + ByRef(context), + ByRef(empty_rejected_param_), + std::string()))); times++; // call new SSLContext creation @@ -1802,34 +1944,33 @@ TEST_F(ProtocolHandlerImplTest, ContextCreationStrategy::kUseExisting)) . // Return new SSLContext - WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), Return(&ssl_context_mock))); + WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(&ssl_context_mock))); times++; // Initilization check EXPECT_CALL(ssl_context_mock, IsInitCompleted()) . // emulate SSL is not initilized - WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(false))); + WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(false))); times++; // Pending handshake check EXPECT_CALL(ssl_context_mock, IsHandshakePending()) . // emulate is pending - WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(false))); + WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(false))); times++; // Wait restart handshake operation EXPECT_CALL(security_manager_mock, StartHandshake(connection_key)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; // Expect add listener for handshake result EXPECT_CALL(security_manager_mock, AddListener(_)) // Emulate handshake .WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), + DoAll(NotifyTestAsyncWaiter(waiter), Invoke(OnHandshakeDoneFunctor( connection_key, security_manager::SSLContext::Handshake_Result_Success)))); @@ -1840,30 +1981,30 @@ TEST_F(ProtocolHandlerImplTest, GetSSLContext(connection_key, start_service)) . // Emulate protection for service is not enabled - WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), ReturnNull())); + WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), ReturnNull())); times++; EXPECT_CALL(security_manager_mock, IsSystemTimeProviderReady()) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(true))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); times++; EXPECT_CALL(session_observer_mock, SetProtectionFlag(connection_key, start_service)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; // Expect send Ack with PROTECTION_ON (on successfull handshake) EXPECT_CALL(transport_manager_mock, SendMessageToDevice( ControlMessage(FRAME_DATA_START_SERVICE_ACK, PROTECTION_ON))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; SendControlMessage( PROTECTION_ON, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } #endif // ENABLE_SECURITY @@ -1883,7 +2024,7 @@ void ProtocolHandlerImplTest::VerifySecondaryTransportParamsInStartSessionAck( .WillRepeatedly(Return(maximum_rpc_payload_size)); InitProtocolHandlerImpl(0u, 0u); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; const uint8_t input_protocol_version = 5; @@ -1988,14 +2129,14 @@ void ProtocolHandlerImplTest::VerifySecondaryTransportParamsInStartSessionAck( transport_manager_mock, SendMessageToDevice(ControlMessage( FRAME_DATA_START_SERVICE_ACK, PROTECTION_OFF, connection_id, _))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; #ifdef ENABLE_SECURITY AddSecurityManager(); EXPECT_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) - .WillOnce(Return(connection_key)); + .WillRepeatedly(Return(connection_key)); EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, kRpc)) .WillOnce(ReturnNull()); @@ -2009,7 +2150,7 @@ void ProtocolHandlerImplTest::VerifySecondaryTransportParamsInStartSessionAck( false /* protection */, full_version); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } void ProtocolHandlerImplTest::VerifyCloudAppParamsInStartSessionAck( @@ -2019,7 +2160,7 @@ void ProtocolHandlerImplTest::VerifyCloudAppParamsInStartSessionAck( .WillRepeatedly(Return(maximum_rpc_payload_size)); InitProtocolHandlerImpl(0u, 0u); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; const uint8_t input_protocol_version = 5; @@ -2100,14 +2241,14 @@ void ProtocolHandlerImplTest::VerifyCloudAppParamsInStartSessionAck( PROTECTION_OFF, connection_id, Eq(expected_param)))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; #ifdef ENABLE_SECURITY AddSecurityManager(); EXPECT_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) - .WillOnce(Return(connection_key)); + .WillRepeatedly(Return(connection_key)); EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, kRpc)) .WillOnce(ReturnNull()); @@ -2119,11 +2260,11 @@ void ProtocolHandlerImplTest::VerifyCloudAppParamsInStartSessionAck( session_id, input_protocol_version, hash_id, - protocol_handler::SERVICE_TYPE_RPC, + kRpc, false /* protection */, full_version); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } TEST_F(ProtocolHandlerImplTest, @@ -2487,7 +2628,7 @@ TEST_F( // Secondary transport param should not be included for apps with v5.0.0 TEST_F(ProtocolHandlerImplTest, StartSessionAck_Unprotected_NoSecondaryTransportParamsForV5) { - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; const uint8_t input_protocol_version = 5; @@ -2558,7 +2699,7 @@ TEST_F(ProtocolHandlerImplTest, PROTECTION_OFF, connection_id, Eq(expected_param)))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; connection_handler::SessionTransports dummy_st = {0, 0}; @@ -2577,7 +2718,7 @@ TEST_F(ProtocolHandlerImplTest, AddSecurityManager(); EXPECT_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) - .WillOnce(Return(connection_key)); + .WillRepeatedly(Return(connection_key)); EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, kRpc)) .WillOnce(ReturnNull()); @@ -2587,11 +2728,11 @@ TEST_F(ProtocolHandlerImplTest, session_id, input_protocol_version, hash_id, - protocol_handler::SERVICE_TYPE_RPC, + kRpc, false /* protection */, full_version); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } TEST_F(ProtocolHandlerImplTest, StartSessionAck_PrimaryTransportUSBHostMode) { @@ -2659,7 +2800,7 @@ TEST_F(ProtocolHandlerImplTest, StartSessionAck_CloudAppAuthTokenAvailable) { TEST_F(ProtocolHandlerImplTest, TransportEventUpdate_afterVersionNegotiation_TCPEnabled) { - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; const uint8_t input_protocol_version = 5; @@ -2729,7 +2870,7 @@ TEST_F(ProtocolHandlerImplTest, transport_manager_mock, SendMessageToDevice(ControlMessage( FRAME_DATA_START_SERVICE_ACK, PROTECTION_OFF, connection_id, _))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; EXPECT_CALL(session_observer_mock, ProtocolVersionUsed(_, _, An())) @@ -2756,14 +2897,14 @@ TEST_F(ProtocolHandlerImplTest, PROTECTION_OFF, connection_id, Eq(expected_param)))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; #ifdef ENABLE_SECURITY AddSecurityManager(); EXPECT_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) - .WillOnce(Return(connection_key)); + .WillRepeatedly(Return(connection_key)); EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, kRpc)) .WillOnce(ReturnNull()); @@ -2773,16 +2914,16 @@ TEST_F(ProtocolHandlerImplTest, session_id, input_protocol_version, hash_id, - protocol_handler::SERVICE_TYPE_RPC, + kRpc, false /* protection */, full_version); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } TEST_F(ProtocolHandlerImplTest, TransportEventUpdate_afterVersionNegotiation_TCPDisabled) { - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; const uint8_t input_protocol_version = 5; @@ -2850,7 +2991,7 @@ TEST_F(ProtocolHandlerImplTest, transport_manager_mock, SendMessageToDevice(ControlMessage( FRAME_DATA_START_SERVICE_ACK, PROTECTION_OFF, connection_id, _))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; EXPECT_CALL(session_observer_mock, ProtocolVersionUsed(_, _, An())) @@ -2877,14 +3018,14 @@ TEST_F(ProtocolHandlerImplTest, PROTECTION_OFF, connection_id, Eq(expected_param)))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; #ifdef ENABLE_SECURITY AddSecurityManager(); EXPECT_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) - .WillOnce(Return(connection_key)); + .WillRepeatedly(Return(connection_key)); EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, kRpc)) .WillOnce(ReturnNull()); @@ -2894,11 +3035,11 @@ TEST_F(ProtocolHandlerImplTest, session_id, input_protocol_version, hash_id, - protocol_handler::SERVICE_TYPE_RPC, + kRpc, false /* protection */, full_version); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } TEST_F(ProtocolHandlerImplTest, @@ -2906,7 +3047,7 @@ TEST_F(ProtocolHandlerImplTest, using connection_handler::SessionConnectionMap; using connection_handler::SessionTransports; - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; char tcp_address[] = "172.16.2.3"; @@ -2960,12 +3101,12 @@ TEST_F(ProtocolHandlerImplTest, PROTECTION_OFF, device2_primary_connection_id, Eq(expected_param)))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; tm_listener->OnTransportConfigUpdated(configs); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } TEST_F(ProtocolHandlerImplTest, @@ -2973,7 +3114,7 @@ TEST_F(ProtocolHandlerImplTest, using connection_handler::SessionConnectionMap; using connection_handler::SessionTransports; - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; char tcp_address[] = "172.16.2.3"; @@ -3030,7 +3171,7 @@ TEST_F(ProtocolHandlerImplTest, PROTECTION_OFF, device1_primary_connection_id, Eq(expected_param)))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; EXPECT_CALL( transport_manager_mock, @@ -3038,18 +3179,18 @@ TEST_F(ProtocolHandlerImplTest, PROTECTION_OFF, device3_primary_connection_id, Eq(expected_param)))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; tm_listener->OnTransportConfigUpdated(configs); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } TEST_F(ProtocolHandlerImplTest, RegisterSecondaryTransport_SUCCESS) { AddConnection(); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; transport_manager::ConnectionUID primary_connection_id = 123; @@ -3069,7 +3210,7 @@ TEST_F(ProtocolHandlerImplTest, RegisterSecondaryTransport_SUCCESS) { PROTECTION_OFF, connection_id, _))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; SendControlMessage(PROTECTION_OFF, @@ -3078,13 +3219,13 @@ TEST_F(ProtocolHandlerImplTest, RegisterSecondaryTransport_SUCCESS) { FRAME_DATA_REGISTER_SECONDARY_TRANSPORT, PROTOCOL_VERSION_5); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } TEST_F(ProtocolHandlerImplTest, RegisterSecondaryTransport_FAILURE) { AddConnection(); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; transport_manager::ConnectionUID primary_connection_id = 123; @@ -3105,7 +3246,7 @@ TEST_F(ProtocolHandlerImplTest, RegisterSecondaryTransport_FAILURE) { PROTECTION_OFF, connection_id, _))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times++; SendControlMessage(PROTECTION_OFF, @@ -3114,16 +3255,16 @@ TEST_F(ProtocolHandlerImplTest, RegisterSecondaryTransport_FAILURE) { FRAME_DATA_REGISTER_SECONDARY_TRANSPORT, PROTOCOL_VERSION_5); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } -TEST_F(ProtocolHandlerImplTest, DISABLED_FloodVerification) { +TEST_F(ProtocolHandlerImplTest, FloodVerification) { const size_t period_msec = 10000; const size_t max_messages = 1000; InitProtocolHandlerImpl(period_msec, max_messages); AddConnection(); - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); @@ -3133,6 +3274,14 @@ TEST_F(ProtocolHandlerImplTest, DISABLED_FloodVerification) { .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; + ON_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) + .WillByDefault(Return(connection_key)); + + connection_handler::SessionTransports st; + st.primary_transport = connection_id; + ON_CALL(connection_handler_mock, GetSessionTransports(session_id)) + .WillByDefault(Return(st)); + ON_CALL(protocol_handler_settings_mock, message_frequency_time()) .WillByDefault(Return(period_msec)); ON_CALL(protocol_handler_settings_mock, message_frequency_count()) @@ -3148,19 +3297,19 @@ TEST_F(ProtocolHandlerImplTest, DISABLED_FloodVerification) { session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); } - EXPECT_TRUE(waiter->WaitFor(times, period_msec)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } -TEST_F(ProtocolHandlerImplTest, DISABLED_FloodVerification_ThresholdValue) { +TEST_F(ProtocolHandlerImplTest, FloodVerification_ThresholdValue) { const size_t period_msec = 10000; const size_t max_messages = 1000; InitProtocolHandlerImpl(period_msec, max_messages); AddConnection(); - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); @@ -3170,10 +3319,18 @@ TEST_F(ProtocolHandlerImplTest, DISABLED_FloodVerification_ThresholdValue) { ON_CALL(protocol_handler_settings_mock, message_frequency_count()) .WillByDefault(Return(max_messages)); + ON_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) + .WillByDefault(Return(connection_key)); + // Expect NO flood notification to CH EXPECT_CALL(session_observer_mock, OnApplicationFloodCallBack(connection_key)) .Times(0); + connection_handler::SessionTransports st; + st.primary_transport = connection_id; + ON_CALL(connection_handler_mock, GetSessionTransports(session_id)) + .WillByDefault(Return(st)); + for (size_t i = 0; i < max_messages - 1; ++i) { SendTMMessage(connection_id, PROTOCOL_VERSION_3, @@ -3184,23 +3341,31 @@ TEST_F(ProtocolHandlerImplTest, DISABLED_FloodVerification_ThresholdValue) { session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); } - EXPECT_TRUE(waiter->WaitFor(times, period_msec)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } -TEST_F(ProtocolHandlerImplTest, DISABLED_FloodVerification_VideoFrameSkip) { +TEST_F(ProtocolHandlerImplTest, FloodVerification_VideoFrameSkip) { const size_t period_msec = 10000; const size_t max_messages = 1000; InitProtocolHandlerImpl(period_msec, max_messages); AddConnection(); - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); + connection_handler::SessionTransports st; + st.primary_transport = connection_id; + ON_CALL(connection_handler_mock, GetSessionTransports(session_id)) + .WillByDefault(Return(st)); + + ON_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) + .WillByDefault(Return(connection_key)); + // Expect NO flood notification to CH on video data streaming for (size_t i = 0; i < max_messages + 1; ++i) { SendTMMessage(connection_id, @@ -3212,23 +3377,31 @@ TEST_F(ProtocolHandlerImplTest, DISABLED_FloodVerification_VideoFrameSkip) { session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); } - EXPECT_TRUE(waiter->WaitFor(times, period_msec)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } -TEST_F(ProtocolHandlerImplTest, DISABLED_FloodVerification_AudioFrameSkip) { +TEST_F(ProtocolHandlerImplTest, FloodVerification_AudioFrameSkip) { const size_t period_msec = 10000; const size_t max_messages = 1000; InitProtocolHandlerImpl(period_msec, max_messages); AddConnection(); - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); + connection_handler::SessionTransports st; + st.primary_transport = connection_id; + ON_CALL(connection_handler_mock, GetSessionTransports(session_id)) + .WillByDefault(Return(st)); + + ON_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) + .WillByDefault(Return(connection_key)); + // Expect NO flood notification to CH on video data streaming for (size_t i = 0; i < max_messages + 1; ++i) { SendTMMessage(connection_id, @@ -3240,23 +3413,31 @@ TEST_F(ProtocolHandlerImplTest, DISABLED_FloodVerification_AudioFrameSkip) { session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); } - EXPECT_TRUE(waiter->WaitFor(times, period_msec)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } -TEST_F(ProtocolHandlerImplTest, DISABLED_FloodVerificationDisable) { +TEST_F(ProtocolHandlerImplTest, FloodVerificationDisable) { const size_t period_msec = 0; const size_t max_messages = 0; InitProtocolHandlerImpl(period_msec, max_messages); AddConnection(); - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); + connection_handler::SessionTransports st; + st.primary_transport = connection_id; + ON_CALL(connection_handler_mock, GetSessionTransports(session_id)) + .WillByDefault(Return(st)); + + ON_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) + .WillByDefault(Return(connection_key)); + // Expect NO flood notification to session observer for (size_t i = 0; i < max_messages + 1; ++i) { SendTMMessage(connection_id, @@ -3268,7 +3449,7 @@ TEST_F(ProtocolHandlerImplTest, DISABLED_FloodVerificationDisable) { session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); } EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); @@ -3280,7 +3461,7 @@ TEST_F(ProtocolHandlerImplTest, MalformedVerificationDisable) { InitProtocolHandlerImpl(0u, 0u, false, period_msec, max_messages); AddConnection(); - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); @@ -3300,19 +3481,19 @@ TEST_F(ProtocolHandlerImplTest, MalformedVerificationDisable) { session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); } EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } -TEST_F(ProtocolHandlerImplTest, DISABLED_MalformedLimitVerification) { +TEST_F(ProtocolHandlerImplTest, MalformedLimitVerification) { const size_t period_msec = 10000; const size_t max_messages = 100; InitProtocolHandlerImpl(0u, 0u, true, period_msec, max_messages); AddConnection(); - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); @@ -3322,6 +3503,14 @@ TEST_F(ProtocolHandlerImplTest, DISABLED_MalformedLimitVerification) { .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; + connection_handler::SessionTransports st; + st.primary_transport = connection_id; + ON_CALL(connection_handler_mock, GetSessionTransports(session_id)) + .WillByDefault(Return(st)); + + ON_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) + .WillByDefault(Return(connection_key)); + // Sending malformed packets const uint8_t malformed_version = PROTOCOL_VERSION_MAX; for (size_t i = 0; i < max_messages * 2; ++i) { @@ -3335,7 +3524,7 @@ TEST_F(ProtocolHandlerImplTest, DISABLED_MalformedLimitVerification) { session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); // Common message SendTMMessage(connection_id, PROTOCOL_VERSION_1, @@ -3346,20 +3535,19 @@ TEST_F(ProtocolHandlerImplTest, DISABLED_MalformedLimitVerification) { session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); } EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } -TEST_F(ProtocolHandlerImplTest, - DISABLED_MalformedLimitVerification_MalformedStock) { +TEST_F(ProtocolHandlerImplTest, MalformedLimitVerification_MalformedStock) { const size_t period_msec = 10000; const size_t max_messages = 100; InitProtocolHandlerImpl(0u, 0u, true, period_msec, max_messages); AddConnection(); - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); @@ -3369,6 +3557,14 @@ TEST_F(ProtocolHandlerImplTest, .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; + connection_handler::SessionTransports st; + st.primary_transport = connection_id; + ON_CALL(connection_handler_mock, GetSessionTransports(session_id)) + .WillByDefault(Return(st)); + + ON_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) + .WillByDefault(Return(connection_key)); + // Sending malformed packets const uint8_t malformed_version = PROTOCOL_VERSION_MAX; const uint8_t malformed_frame_type = FRAME_TYPE_MAX_VALUE; @@ -3384,7 +3580,7 @@ TEST_F(ProtocolHandlerImplTest, session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); // Malformed message 2 SendTMMessage(connection_id, PROTOCOL_VERSION_1, @@ -3395,7 +3591,7 @@ TEST_F(ProtocolHandlerImplTest, session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); // Malformed message 3 SendTMMessage(connection_id, PROTOCOL_VERSION_1, @@ -3406,7 +3602,7 @@ TEST_F(ProtocolHandlerImplTest, session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); // Common message SendTMMessage(connection_id, @@ -3418,7 +3614,7 @@ TEST_F(ProtocolHandlerImplTest, session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); } EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); @@ -3430,7 +3626,7 @@ TEST_F(ProtocolHandlerImplTest, MalformedLimitVerification_MalformedOnly) { InitProtocolHandlerImpl(0u, 0u, true, period_msec, max_messages); AddConnection(); - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); @@ -3454,7 +3650,7 @@ TEST_F(ProtocolHandlerImplTest, MalformedLimitVerification_MalformedOnly) { session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); // Malformed message 2 SendTMMessage(connection_id, PROTOCOL_VERSION_1, @@ -3465,7 +3661,7 @@ TEST_F(ProtocolHandlerImplTest, MalformedLimitVerification_MalformedOnly) { session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); // Malformed message 3 SendTMMessage(connection_id, PROTOCOL_VERSION_1, @@ -3476,7 +3672,7 @@ TEST_F(ProtocolHandlerImplTest, MalformedLimitVerification_MalformedOnly) { session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); // No common message } @@ -3490,7 +3686,7 @@ TEST_F(ProtocolHandlerImplTest, MalformedLimitVerification_NullTimePeriod) { InitProtocolHandlerImpl(0u, 0u, true, period_msec, max_messages); AddConnection(); - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); @@ -3511,7 +3707,7 @@ TEST_F(ProtocolHandlerImplTest, MalformedLimitVerification_NullTimePeriod) { session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); } EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); @@ -3523,7 +3719,7 @@ TEST_F(ProtocolHandlerImplTest, MalformedLimitVerification_NullCount) { InitProtocolHandlerImpl(0u, 0u, true, period_msec, max_messages); AddConnection(); - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); @@ -3544,7 +3740,7 @@ TEST_F(ProtocolHandlerImplTest, MalformedLimitVerification_NullCount) { session_id, some_data.size(), message_id, - &some_data[0]); + some_data.data()); } EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); @@ -3565,7 +3761,7 @@ TEST_F(ProtocolHandlerImplTest, OnFinalMessageCallback) { session_id, total_data_size, message_id, - &data[0])); + data.data())); using RawFordMessageToMobile = protocol_handler::impl::RawFordMessageToMobile; using Handler = protocol_handler::impl::ToMobileQueue::Handler; @@ -3613,18 +3809,20 @@ TEST_F(ProtocolHandlerImplTest, protocol_handler_impl->SendEndSession(connection_id, session_id); } -TEST_F(ProtocolHandlerImplTest, - DISABLED_SendEndServicePrivate_EndSession_MessageSent) { +TEST_F(ProtocolHandlerImplTest, SendEndServicePrivate_EndSession_MessageSent) { // Arrange - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); + ON_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) + .WillByDefault(Return(connection_key)); + // Expect check connection with ProtocolVersionUsed EXPECT_CALL(session_observer_mock, ProtocolVersionUsed(connection_id, session_id, An())) - .WillOnce(Return(true)); + .WillOnce(DoAll(SetArgReferee<2>(PROTOCOL_VERSION_3), Return(true))); // Expect send End Service EXPECT_CALL( transport_manager_mock, @@ -3640,7 +3838,7 @@ TEST_F(ProtocolHandlerImplTest, TEST_F(ProtocolHandlerImplTest, SendEndServicePrivate_ServiceTypeControl_MessageSent) { // Arrange - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); @@ -3679,7 +3877,7 @@ TEST_F(ProtocolHandlerImplTest, SendHeartBeat_NoConnection_NotSent) { TEST_F(ProtocolHandlerImplTest, SendHeartBeat_Successful) { // Arrange - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); @@ -3704,7 +3902,7 @@ TEST_F(ProtocolHandlerImplTest, SendHeartBeat_Successful) { TEST_F(ProtocolHandlerImplTest, SendHeartBeatAck_Successful) { // Arrange - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); @@ -3732,13 +3930,39 @@ TEST_F(ProtocolHandlerImplTest, SendHeartBeatAck_Successful) { } TEST_F(ProtocolHandlerImplTest, - DISABLED_SendHeartBeatAck_WrongProtocolVersion_NotSent) { + SendHeartBeatAck_ProtocolVersionUsedFail_Cancelled) { + // Arrange + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + AddSession(waiter, times); + // ProtocolVersionUsed fails + EXPECT_CALL(session_observer_mock, + ProtocolVersionUsed(connection_id, _, An())) + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), + SetArgReferee<2>(PROTOCOL_VERSION_3), + Return(true))) + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(false))); + times += 2; + // Expect no HeartBeatAck sent + EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_)).Times(0); + // Act + SendControlMessage( + PROTECTION_OFF, kControl, session_id, FRAME_DATA_HEART_BEAT); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); +} + +TEST_F(ProtocolHandlerImplTest, SendHeartBeatAck_WrongProtocolVersion_NotSent) { // Arrange - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); + ON_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) + .WillByDefault(Return(connection_key)); + // Expect two checks of connection and protocol version with // ProtocolVersionUsed EXPECT_CALL(session_observer_mock, @@ -3765,17 +3989,16 @@ TEST_F(ProtocolHandlerImplTest, TEST_F(ProtocolHandlerImplTest, SendMessageToMobileApp_SendSingleControlMessage) { // Arrange - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); - 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], + data.data(), total_data_size, false, kControl); @@ -3799,7 +4022,7 @@ TEST_F(ProtocolHandlerImplTest, times++; // Act - protocol_handler_impl->SendMessageToMobileApp(message, false, is_final); + protocol_handler_impl->SendMessageToMobileApp(message, false, kFinalMessage); EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } @@ -3807,17 +4030,16 @@ TEST_F(ProtocolHandlerImplTest, TEST_F(ProtocolHandlerImplTest, SendMessageToMobileApp_SendSingleNonControlMessage) { // Arrange - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); - 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], + data.data(), total_data_size, false, kRpc); @@ -3846,25 +4068,24 @@ TEST_F(ProtocolHandlerImplTest, times++; // Act - protocol_handler_impl->SendMessageToMobileApp(message, false, is_final); + protocol_handler_impl->SendMessageToMobileApp(message, false, kFinalMessage); EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } TEST_F(ProtocolHandlerImplTest, SendMessageToMobileApp_SendMultiframeMessage) { // Arrange - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); - const bool is_final = true; 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], + data.data(), total_data_size, false, kBulk); @@ -3905,75 +4126,1136 @@ TEST_F(ProtocolHandlerImplTest, SendMessageToMobileApp_SendMultiframeMessage) { times++; // Act - protocol_handler_impl->SendMessageToMobileApp(message, false, is_final); + protocol_handler_impl->SendMessageToMobileApp(message, false, kFinalMessage); EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } -TEST_F(ProtocolHandlerImplTest, SendServiceDataAck_PreVersion5) { - std::shared_ptr waiter = std::make_shared(); +TEST_F(ProtocolHandlerImplTest, + SendMessageToMobileApp_NullMessagePointer_Cancelled) { + // Arrange + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); - EXPECT_CALL(session_observer_mock, PairFromKey(connection_key, _, _)) - .WillOnce( - DoAll(SetArgPointee<1>(connection_id), SetArgPointee<2>(session_id))); - EXPECT_CALL(session_observer_mock, - ProtocolVersionUsed(connection_id, _, An())) - .WillRepeatedly( - DoAll(SetArgReferee<2>(PROTOCOL_VERSION_4), Return(true))); - - EXPECT_CALL(transport_manager_mock, - SendMessageToDevice(ExpectedMessage(FRAME_TYPE_CONTROL, - FRAME_DATA_SERVICE_DATA_ACK, - PROTECTION_OFF, - kMobileNav))) - .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); - times++; - - protocol_handler_impl->SendFramesNumber(connection_key, 0); +#ifdef ENABLE_SECURITY + EXPECT_CALL(session_observer_mock, GetSSLContext(_, _)).Times(0); +#endif // ENABLE_SECURITY + EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_)).Times(0); + // Act + RawMessagePtr message; + protocol_handler_impl->SendMessageToMobileApp(message, false, kFinalMessage); EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } -TEST_F(ProtocolHandlerImplTest, SendServiceDataAck_AfterVersion5) { - std::shared_ptr waiter = std::make_shared(); - uint32_t times = 0; +#ifdef ENABLE_SECURITY +TEST_F(ProtocolHandlerImplTest, + OnTMMessageSend_ReadyToCloseConnection_Disconnect) { + OnTMMessageSend(); + const uint8_t data_size = 0u; + ProtocolFramePtr protocol_packet = + std::make_shared(connection_id, + PROTOCOL_VERSION_3, + PROTECTION_OFF, + FRAME_TYPE_SINGLE, + kRpc, + FRAME_DATA_SINGLE, + session_id, + data_size, + message_id, + null_data_); + + RawMessagePtr message = protocol_packet->serializePacket(); + EXPECT_CALL(session_observer_mock, + PairFromKey(message->connection_key(), _, _)) + .WillOnce( + DoAll(SetArgPointee<1>(connection_id), SetArgPointee<2>(session_id))); - AddSession(waiter, times); + EXPECT_CALL(transport_manager_mock, Disconnect(connection_id)); + EXPECT_CALL(session_observer_mock, OnFinalMessageCallback(connection_id)); + EXPECT_CALL(session_observer_mock, ProtocolVersionUsed(_, _, An())) + .Times(0); - EXPECT_CALL(session_observer_mock, PairFromKey(connection_key, _, _)) + tm_listener->OnTMMessageSend(message); +} +#endif + +TEST_F(ProtocolHandlerImplTest, OnTMMessageSend_InvalidData_Cancelled) { + const uint8_t data_size = 8u; + uint8_t data[data_size]; + // Create invalid data + for (uint8_t i = 0; i < data_size; ++i) { + data[i] = -1; + } + RawMessagePtr message = std::make_shared( + connection_key, PROTOCOL_VERSION_3, data, data_size, PROTECTION_OFF); + EXPECT_CALL(session_observer_mock, + PairFromKey(message->connection_key(), _, _)) .WillOnce( DoAll(SetArgPointee<1>(connection_id), SetArgPointee<2>(session_id))); - EXPECT_CALL(session_observer_mock, - ProtocolVersionUsed(connection_id, _, An())) - .WillRepeatedly( - DoAll(SetArgReferee<2>(PROTOCOL_VERSION_5), Return(true))); - // It is expected that Service Data ACK is NOT sent for version 5+ - EXPECT_CALL(transport_manager_mock, - SendMessageToDevice(ExpectedMessage(FRAME_TYPE_CONTROL, - FRAME_DATA_SERVICE_DATA_ACK, - PROTECTION_OFF, - kMobileNav))) + EXPECT_CALL(transport_manager_mock, Disconnect(0)).Times(0); + EXPECT_CALL(session_observer_mock, ProtocolVersionUsed(_, _, An())) .Times(0); - protocol_handler_impl->SendFramesNumber(connection_key, 0); + tm_listener->OnTMMessageSend(message); +} - EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); +TEST_F(ProtocolHandlerImplTest, SendFrame_NullMessage_FAIL) { + auto protocol_handler_implas_listener = + static_cast( + protocol_handler_impl.get()); + EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_)).Times(0); + protocol_handler::impl::RawFordMessageToMobile null_message; + protocol_handler_implas_listener->Handle(null_message); } -/* - * ProtocolHandler shall send StartServiceNAK with a reason param when starting - * a video/audio service if the service type is disallowed by the settings - */ -TEST_F(ProtocolHandlerImplTest, StartSession_NACKReason_DisallowedBySettings) { - const ServiceType service_type = kMobileNav; - const utils::SemanticVersion min_reason_param_version(5, 3, 0); +TEST_F(ProtocolHandlerImplTest, SendFrame_SendMessageToDeviceFailed_FAIL) { + auto protocol_handler_implas_listener = + static_cast( + protocol_handler_impl.get()); + protocol_handler::impl::RawFordMessageToMobile message( + std::make_shared(connection_id, + PROTOCOL_VERSION_3, + PROTECTION_OFF, + FRAME_TYPE_CONTROL, + kControl, + FRAME_DATA_HEART_BEAT, + session_id, + some_data.size(), + message_id, + some_data.data()), + kFinalMessage); + EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_)) + .WillOnce(Return(transport_manager::E_INTERNAL_ERROR)); + protocol_handler_implas_listener->Handle(message); +} -#ifdef ENABLE_SECURITY - AddSecurityManager(); +TEST_F(ProtocolHandlerImplTest, Handle_SingleFrameMessage_SUCCESS) { + auto protocol_handler_implas_listener = + static_cast( + protocol_handler_impl.get()); + const uint8_t data_size = 1u; + protocol_handler::impl::RawFordMessageFromMobile message( + std::make_shared(connection_id, + PROTOCOL_VERSION_3, + PROTECTION_OFF, + FRAME_TYPE_SINGLE, + kControl, + FRAME_DATA_SINGLE, + session_id, + data_size, + message_id, + some_data.data())); + + connection_handler::SessionTransports st; + st.primary_transport = connection_id; + ON_CALL(connection_handler_mock, GetSessionTransports(session_id)) + .WillByDefault(Return(st)); + + protocol_handler_impl->SetTelemetryObserver(&telemetry_observer_mock); + EXPECT_CALL(telemetry_observer_mock, EndMessageProcess(_)); + + protocol_handler_implas_listener->Handle(message); +} + +TEST_F(ProtocolHandlerImplTest, + HandleControlMessageEndServiceACK_SessionKeyZero_FAIL) { + auto protocol_handler_impl_as_listener = + static_cast( + protocol_handler_impl.get()); + protocol_handler::impl::RawFordMessageFromMobile message( + std::make_shared( + connection_id, + PROTOCOL_VERSION_3, + PROTECTION_OFF, + FRAME_TYPE_CONTROL, + kControl, + FRAME_DATA_END_SERVICE_ACK, + session_id, + some_data.size(), + message_id, + some_data.data())); + + EXPECT_CALL(session_observer_mock, + OnSessionEndedCallback(connection_id, + session_id, + An(), + kControl, + An())) + .WillOnce(Return(kInvalidSessionId)); + + protocol_handler_impl_as_listener->Handle(message); +} + +TEST_F(ProtocolHandlerImplTest, Handle_ControlMessage_EndServiceACK_SUCCESS) { + auto protocol_handler_impl_as_listener = + static_cast( + protocol_handler_impl.get()); + protocol_handler::impl::RawFordMessageFromMobile message( + std::make_shared( + connection_id, + PROTOCOL_VERSION_3, + PROTECTION_OFF, + FRAME_TYPE_CONTROL, + kControl, + FRAME_DATA_END_SERVICE_ACK, + session_id, + some_data.size(), + message_id, + some_data.data())); + EXPECT_CALL(session_observer_mock, + OnSessionEndedCallback(connection_id, + session_id, + An(), + kControl, + An())) + .WillOnce(Return(kValidSessionId)); + + protocol_handler_impl_as_listener->Handle(message); +} + +TEST_F(ProtocolHandlerImplTest, Handle_ControlMessage_HeartBeatAck_SUCCESS) { + auto protocol_handler_impl_as_listener = + static_cast( + protocol_handler_impl.get()); + protocol_handler::impl::RawFordMessageFromMobile message( + std::make_shared( + connection_id, + PROTOCOL_VERSION_3, + PROTECTION_OFF, + FRAME_TYPE_CONTROL, + kControl, + FRAME_DATA_HEART_BEAT_ACK, + session_id, + some_data.size(), + message_id, + some_data.data())); + EXPECT_CALL(session_observer_mock, + OnSessionEndedCallback(_, _, An(), _)) + .Times(0); + EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(_, _, _, _, _)) + .Times(0); + + protocol_handler_impl_as_listener->Handle(message); +} + +TEST_F(ProtocolHandlerImplTest, Handle_ControlMessage_Default_SUCCESS) { + auto protocol_handler_impl_as_listener = + static_cast( + protocol_handler_impl.get()); + protocol_handler::impl::RawFordMessageFromMobile message( + std::make_shared( + connection_id, + PROTOCOL_VERSION_3, + PROTECTION_OFF, + FRAME_TYPE_CONTROL, + kControl, + FRAME_DATA_END_SERVICE_NACK, + session_id, + some_data.size(), + message_id, + some_data.data())); + EXPECT_CALL(session_observer_mock, + OnSessionEndedCallback(_, _, An(), _)) + .Times(0); + EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(_, _, _, _, _)) + .Times(0); + + protocol_handler_impl_as_listener->Handle(message); +} + +TEST_F(ProtocolHandlerImplTest, + GetHashId_FirstProtocolVersion_HashNotSupported) { + auto protocol_handler_impl_as_listener = + static_cast( + protocol_handler_impl.get()); + protocol_handler::impl::RawFordMessageFromMobile message( + std::make_shared( + connection_id, + PROTOCOL_VERSION_1, + PROTECTION_OFF, + FRAME_TYPE_CONTROL, + kControl, + FRAME_DATA_END_SERVICE_ACK, + session_id, + some_data.size(), + message_id, + some_data.data())); + + uint32_t hash_id; + EXPECT_CALL(session_observer_mock, + OnSessionEndedCallback(connection_id, + session_id, + An(), + kControl, + An())) + .WillOnce(DoAll(SaveArgPointee<2>(&hash_id), Return(kInvalidSessionId))); + + protocol_handler_impl_as_listener->Handle(message); + + EXPECT_EQ(hash_id, protocol_handler::HASH_ID_NOT_SUPPORTED); +} + +TEST_F(ProtocolHandlerImplTest, GetHashId_SecondProtocolVersion_HashWrong) { + auto protocol_handler_impl_as_listener = + static_cast( + protocol_handler_impl.get()); + + some_data.resize(3); + std::fill(some_data.begin(), some_data.end(), 0xAA); + + protocol_handler::impl::RawFordMessageFromMobile message( + std::make_shared( + connection_id, + PROTOCOL_VERSION_2, + PROTECTION_OFF, + FRAME_TYPE_CONTROL, + kControl, + FRAME_DATA_END_SERVICE_ACK, + session_id, + some_data.size(), + message_id, + some_data.data())); + + uint32_t hash_id; + EXPECT_CALL(session_observer_mock, + OnSessionEndedCallback(connection_id, + session_id, + An(), + kControl, + An())) + .WillOnce(DoAll(SaveArgPointee<2>(&hash_id), Return(kInvalidSessionId))); + + protocol_handler_impl_as_listener->Handle(message); + + EXPECT_EQ(hash_id, protocol_handler::HASH_ID_WRONG); +} + +TEST_F(ProtocolHandlerImplTest, GetHashId_CorrectData_CorrectHash) { + auto protocol_handler_impl_as_listener = + static_cast( + protocol_handler_impl.get()); + + // 4 - because hash id not works with data.size < 4 + some_data.resize(4); + std::fill(some_data.begin(), some_data.end(), 0xAA); + + protocol_handler::impl::RawFordMessageFromMobile message( + std::make_shared( + connection_id, + PROTOCOL_VERSION_3, + PROTECTION_OFF, + FRAME_TYPE_CONTROL, + kControl, + FRAME_DATA_END_SERVICE_ACK, + session_id, + some_data.size(), + message_id, + some_data.data())); + + const uint32_t exp_hash_id = + BE_TO_LE32(*(reinterpret_cast(some_data.data()))); + uint32_t hash_id; + + EXPECT_CALL(session_observer_mock, + OnSessionEndedCallback(connection_id, + session_id, + An(), + kControl, + An())) + .WillOnce(DoAll(SaveArgPointee<2>(&hash_id), Return(kValidSessionId))); + + protocol_handler_impl_as_listener->Handle(message); + + EXPECT_EQ(hash_id, exp_hash_id); +} + +TEST_F(ProtocolHandlerImplTest, GetHashId_InvalidData_WrongHash) { + auto protocol_handler_impl_as_listener = + static_cast( + protocol_handler_impl.get()); + + some_data.resize(8); + std::fill(some_data.begin(), some_data.end(), 0); + + protocol_handler::impl::RawFordMessageFromMobile message( + std::make_shared( + connection_id, + PROTOCOL_VERSION_3, + PROTECTION_OFF, + FRAME_TYPE_CONTROL, + kControl, + FRAME_DATA_END_SERVICE_ACK, + session_id, + some_data.size(), + message_id, + some_data.data())); + + uint32_t hash_id; + EXPECT_CALL(session_observer_mock, + OnSessionEndedCallback(connection_id, + session_id, + An(), + kControl, + An())) + .WillOnce(DoAll(SaveArgPointee<2>(&hash_id), Return(kValidSessionId))); + + protocol_handler_impl_as_listener->Handle(message); + + EXPECT_EQ(hash_id, protocol_handler::HASH_ID_WRONG); +} + +TEST_F(ProtocolHandlerImplTest, GetHashId_ProtocolVersion5_ValidData) { + auto protocol_handler_impl_as_listener = + static_cast( + protocol_handler_impl.get()); + + const uint8_t data_size = 5u; + uint8_t data[data_size] = {data_size}; + + BsonObject obj = bson_object_from_bytes(data); + const uint32_t exp_hash_id = + (uint32_t)bson_object_get_int32(&obj, protocol_handler::strings::hash_id); + bson_object_deinitialize(&obj); + + protocol_handler::impl::RawFordMessageFromMobile message( + std::make_shared( + connection_id, + PROTOCOL_VERSION_5, + PROTECTION_OFF, + FRAME_TYPE_CONTROL, + kControl, + FRAME_DATA_END_SERVICE_ACK, + session_id, + data_size, + message_id, + data)); + + uint32_t hash_id; + EXPECT_CALL(session_observer_mock, + OnSessionEndedCallback(connection_id, + session_id, + An(), + kControl, + An())) + .WillOnce(DoAll(SaveArgPointee<2>(&hash_id), Return(kValidSessionId))); + + protocol_handler_impl_as_listener->Handle(message); + + EXPECT_EQ(hash_id, exp_hash_id); +} + +TEST_F(ProtocolHandlerImplTest, SetHashId_CorrectHashId) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + const uint8_t input_protocol_version = 3; + utils::SemanticVersion full_version(3, 1, 0); + // hash id should be any except HASH_ID_WRONG(0xFFFF0000) and + // HASH_ID_NOT_SUPPORTED(0) + const uint32_t hash_id = 42; + + const uint32_t hash_id_be = LE_TO_BE32(hash_id); + const uint8_t* exp_data = reinterpret_cast(&hash_id_be); + const uint32_t exp_data_size = sizeof(hash_id_be); + + SetProtocolVersion2(); + + RawMessagePtr raw_message; + EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_)) + .WillOnce(DoAll(SaveArg<0>(&raw_message), + NotifyTestAsyncWaiter(waiter), + Return(transport_manager::E_SUCCESS))); + times++; + + protocol_handler_impl->SendStartSessionAck(connection_id, + session_id, + input_protocol_version, + hash_id, + kRpc, + PROTECTION_OFF, + full_version); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); + ASSERT_NE(0, raw_message.use_count()); + + ProtocolPacket protocol_packet; + RESULT_CODE res = protocol_packet.deserializePacket(raw_message->data(), + raw_message->data_size()); + ASSERT_EQ(protocol_handler::RESULT_CODE::RESULT_OK, res); + + EXPECT_THAT(std::vector(exp_data, exp_data + exp_data_size), + ElementsAreArray(protocol_packet.data(), + protocol_packet.total_data_bytes())); +} + +TEST_F(ProtocolHandlerImplTest, SetHashId_HASH_ID_NOT_SUPPORTED) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + const uint8_t input_protocol_version = 3; + const uint32_t hash_id = protocol_handler::HASH_ID_NOT_SUPPORTED; + utils::SemanticVersion full_version(3, 1, 0); + + SetProtocolVersion2(); + + RawMessagePtr raw_message; + EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_)) + .WillOnce(DoAll(SaveArg<0>(&raw_message), + NotifyTestAsyncWaiter(waiter), + Return(transport_manager::E_SUCCESS))); + times++; + + protocol_handler_impl->SendStartSessionAck(connection_id, + session_id, + input_protocol_version, + hash_id, + kRpc, + PROTECTION_OFF, + full_version); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); + ASSERT_NE(0, raw_message.use_count()); + + ProtocolPacket protocol_packet; + RESULT_CODE res = protocol_packet.deserializePacket(raw_message->data(), + raw_message->data_size()); + ASSERT_EQ(protocol_handler::RESULT_CODE::RESULT_OK, res); + + EXPECT_EQ(0u, protocol_packet.total_data_bytes()); +} + +TEST_F(ProtocolHandlerImplTest, SetHashId_HASH_ID_WRONG) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + const uint8_t input_protocol_version = 3; + const uint32_t hash_id = protocol_handler::HASH_ID_WRONG; + utils::SemanticVersion full_version(3, 1, 0); + + SetProtocolVersion2(); + + RawMessagePtr raw_message; + EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_)) + .WillOnce(DoAll(SaveArg<0>(&raw_message), + NotifyTestAsyncWaiter(waiter), + Return(transport_manager::E_SUCCESS))); + times++; + + protocol_handler_impl->SendStartSessionAck(connection_id, + session_id, + input_protocol_version, + hash_id, + kRpc, + PROTECTION_OFF, + full_version); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); + ASSERT_NE(0, raw_message.use_count()); + + ProtocolPacket protocol_packet; + RESULT_CODE res = protocol_packet.deserializePacket(raw_message->data(), + raw_message->data_size()); + + ASSERT_EQ(protocol_handler::RESULT_CODE::RESULT_OK, res); + + EXPECT_EQ(0u, protocol_packet.total_data_bytes()); +} + +TEST_F(ProtocolHandlerImplTest, PopValidAndExpiredMultiframes) { + using namespace protocol_handler; + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + AddSession(waiter, times); + + const uint8_t data_size = 1u; + uint8_t data = 7u; + ProtocolFramePtr first_frame = CreateFramePtrWithData(data, FRAME_TYPE_FIRST); + ProtocolFramePtr consecutive_frame = + std::make_shared(connection_id, + PROTOCOL_VERSION_3, + PROTECTION_OFF, + FRAME_TYPE_CONSECUTIVE, + kMobileNav, + FRAME_DATA_LAST_CONSECUTIVE, + session_id, + data_size, + message_id, + &data); + + protocol_handler_impl->AddProtocolObserver(&protocol_observer_mock); + + connection_handler::SessionTransports st; + st.primary_transport = connection_id; + ON_CALL(connection_handler_mock, GetSessionTransports(session_id)) + .WillByDefault(Return(st)); + + EXPECT_CALL(session_observer_mock, KeyFromPair(connection_id, _)) + .WillRepeatedly(Return(connection_id)); + + EXPECT_CALL(protocol_observer_mock, OnMessageReceived(_)); + + protocol_handler::impl::FromMobileQueue::Handler* handler = + protocol_handler_impl.get(); + protocol_handler::impl::RawFordMessageFromMobile first_message(first_frame); + handler->Handle(first_message); + protocol_handler::impl::RawFordMessageFromMobile consecutive_message( + consecutive_frame); + handler->Handle(consecutive_message); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); +} + +TEST_F(ProtocolHandlerImplTest, HandleFromMobile_FrameTypeSingle_Handled) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + AddSession(waiter, times); + + const uint8_t data_value = 7u; + ProtocolFramePtr frame_ptr = + CreateFramePtrWithData(data_value, FRAME_TYPE_SINGLE); + + connection_handler::SessionTransports st; + st.primary_transport = connection_id; + ON_CALL(connection_handler_mock, GetSessionTransports(session_id)) + .WillByDefault(Return(st)); + + protocol_handler_impl->AddProtocolObserver(&protocol_observer_mock); + EXPECT_CALL(protocol_observer_mock, OnMessageReceived(_)); + + protocol_handler::impl::FromMobileQueue::Handler* handler = + protocol_handler_impl.get(); + protocol_handler::impl::RawFordMessageFromMobile message(frame_ptr); + handler->Handle(message); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); +} + +#ifdef ENABLE_SECURITY +TEST_F(ProtocolHandlerImplTest, EncryptFrame_NoSecurityManagerSet_Cancelled) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + AddSession(waiter, times); + + const uint8_t data_size = 0u; + ProtocolFramePtr frame_ptr = + std::make_shared(connection_id, + PROTOCOL_VERSION_3, + PROTECTION_OFF, + FRAME_TYPE_SINGLE, + kAudio, + FRAME_DATA_END_SERVICE_ACK, + session_id, + data_size, + message_id, + null_data_); + + EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_)).Times(0); + + protocol_handler::impl::ToMobileQueue::Handler* handler = + protocol_handler_impl.get(); + protocol_handler::impl::RawFordMessageToMobile message(frame_ptr, + kFinalMessage); + handler->Handle(message); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); +} + +TEST_F(ProtocolHandlerImplTest, + EncryptFrame_ControlFrameType_ContinueUnencrypted) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + AddSession(waiter, times); + AddSecurityManager(); + + const uint8_t data_value = 7u; + ProtocolFramePtr frame_ptr = + CreateFramePtrWithData(data_value, FRAME_TYPE_CONTROL); + + RawMessagePtr raw_message; + EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_)) + .WillOnce(DoAll(SaveArg<0>(&raw_message), + NotifyTestAsyncWaiter(waiter), + Return(transport_manager::E_SUCCESS))); + times++; + + protocol_handler::impl::ToMobileQueue::Handler* handler = + protocol_handler_impl.get(); + protocol_handler::impl::RawFordMessageToMobile message(frame_ptr, + kFinalMessage); + handler->Handle(message); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); + ASSERT_NE(0, raw_message.use_count()); + + EXPECT_EQ(data_value, + raw_message->data()[protocol_handler::PROTOCOL_HEADER_V2_SIZE]); +} + +TEST_F(ProtocolHandlerImplTest, + EncryptFrame_SSLContextInitNotCompleted_ContinueUnencrypted) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + AddSession(waiter, times); + AddSecurityManager(); + + const uint8_t data_value = 7u; + ProtocolFramePtr frame_ptr = + CreateFramePtrWithData(data_value, FRAME_TYPE_SINGLE); + + EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, _)) + .WillOnce( + DoAll(NotifyTestAsyncWaiter(waiter), Return(&ssl_context_mock))); + times++; + EXPECT_CALL(ssl_context_mock, IsInitCompleted()) + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(false))); + times++; + + RawMessagePtr raw_message; + EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_)) + .WillOnce(DoAll(SaveArg<0>(&raw_message), + NotifyTestAsyncWaiter(waiter), + Return(transport_manager::E_SUCCESS))); + times++; + + protocol_handler::impl::ToMobileQueue::Handler* handler = + protocol_handler_impl.get(); + protocol_handler::impl::RawFordMessageToMobile message(frame_ptr, + kFinalMessage); + handler->Handle(message); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); + ASSERT_NE(0, raw_message.use_count()); + + EXPECT_EQ(data_value, + raw_message->data()[protocol_handler::PROTOCOL_HEADER_V2_SIZE]); +} + +TEST_F(ProtocolHandlerImplTest, + EncryptFrame_EncryptFailed_ContinueUnencrypted) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + AddSession(waiter, times); + AddSecurityManager(); + + const uint8_t data_value = 7u; + ProtocolFramePtr frame_ptr = + CreateFramePtrWithData(data_value, FRAME_TYPE_SINGLE); + + EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, _)) + .WillOnce( + DoAll(NotifyTestAsyncWaiter(waiter), Return(&ssl_context_mock))); + times++; + + EXPECT_CALL(ssl_context_mock, IsInitCompleted()) + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); + times++; + + EXPECT_CALL(session_observer_mock, + OnSessionEndedCallback(connection_id, + session_id, + An(), + kRpc, + An())); + + const uint8_t data_size = 1u; + EXPECT_CALL(ssl_context_mock, Encrypt(frame_ptr->data(), data_size, _, _)) + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(false))); + times++; + + RawMessagePtr raw_message; + EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_)) + .WillOnce(DoAll(SaveArg<0>(&raw_message), + NotifyTestAsyncWaiter(waiter), + Return(transport_manager::E_SUCCESS))); + times++; + + protocol_handler::impl::ToMobileQueue::Handler* handler = + protocol_handler_impl.get(); + protocol_handler::impl::RawFordMessageToMobile message(frame_ptr, + kFinalMessage); + message->set_protection_flag(PROTECTION_ON); + handler->Handle(message); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); + ASSERT_NE(0, raw_message.use_count()); + + EXPECT_EQ(data_value, + raw_message->data()[protocol_handler::PROTOCOL_HEADER_V2_SIZE]); +} + +TEST_F(ProtocolHandlerImplTest, + EncryptFrame_EncryptSucceeded_ContinueEncrypted) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + AddSession(waiter, times); + AddSecurityManager(); + + const uint8_t data_value = 7u; + ProtocolFramePtr frame_ptr = + CreateFramePtrWithData(data_value, FRAME_TYPE_SINGLE); + + EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, _)) + .WillOnce( + DoAll(NotifyTestAsyncWaiter(waiter), Return(&ssl_context_mock))); + times++; + + EXPECT_CALL(ssl_context_mock, IsInitCompleted()) + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); + times++; + + const uint8_t data_size = 1u; + const uint8_t encrypted_data = 8u; + EXPECT_CALL(ssl_context_mock, Encrypt(frame_ptr->data(), data_size, _, _)) + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), + SetArgPointee<2>(&encrypted_data), + SetArgPointee<3>(data_size), + Return(true))); + times++; + + RawMessagePtr raw_message; + EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_)) + .WillOnce(DoAll(SaveArg<0>(&raw_message), + NotifyTestAsyncWaiter(waiter), + Return(transport_manager::E_SUCCESS))); + times++; + + protocol_handler::impl::ToMobileQueue::Handler* handler = + protocol_handler_impl.get(); + protocol_handler::impl::RawFordMessageToMobile message(frame_ptr, + kFinalMessage); + message->set_protection_flag(PROTECTION_ON); + handler->Handle(message); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); + ASSERT_NE(0, raw_message.use_count()); + + EXPECT_EQ(encrypted_data, + raw_message->data()[protocol_handler::PROTOCOL_HEADER_V2_SIZE]); +} + +TEST_F(ProtocolHandlerImplTest, DecryptFrame_NoSecurityManager_Cancelled) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + AddSession(waiter, times); + + const uint8_t data_size = 1u; + const uint8_t data_value = 7u; + ProtocolFramePtr frame_ptr = + std::make_shared(connection_id, + PROTOCOL_VERSION_3, + PROTECTION_ON, + FRAME_TYPE_SINGLE, + kAudio, + FRAME_DATA_SINGLE, + session_id, + data_size, + message_id, + &data_value); + + EXPECT_CALL(ssl_context_mock, Decrypt(_, _, _, _)).Times(0); + + protocol_handler_impl->SetTelemetryObserver(&telemetry_observer_mock); + EXPECT_CALL(telemetry_observer_mock, StartMessageProcess(message_id, _)) + .Times(0); + + tm_listener->OnTMMessageReceived(frame_ptr->serializePacket()); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); +} + +TEST_F(ProtocolHandlerImplTest, + DecryptFrame_ProtectionFlagOff_ContinueUndecrypted) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + AddSession(waiter, times); + const uint8_t data_size = 1u; + const uint8_t data_value = 7u; + ProtocolFramePtr frame_ptr = + std::make_shared(connection_id, + PROTOCOL_VERSION_3, + PROTECTION_OFF, + FRAME_TYPE_SINGLE, + kAudio, + FRAME_DATA_SINGLE, + session_id, + data_size, + message_id, + &data_value); + EXPECT_CALL(ssl_context_mock, Decrypt(_, _, _, _)).Times(0); + + protocol_handler_impl->SetTelemetryObserver(&telemetry_observer_mock); + EXPECT_CALL(telemetry_observer_mock, StartMessageProcess(message_id, _)); + EXPECT_CALL(telemetry_observer_mock, EndMessageProcess(_)); + + connection_handler::SessionTransports st; + st.primary_transport = connection_id; + ON_CALL(connection_handler_mock, GetSessionTransports(session_id)) + .WillByDefault(Return(st)); + + tm_listener->OnTMMessageReceived(frame_ptr->serializePacket()); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); +} + +TEST_F(ProtocolHandlerImplTest, + DecryptFrame_FrameTypeControl_ContinueUndecrypted) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + AddSession(waiter, times); + + ON_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) + .WillByDefault(Return(connection_key)); + + const uint8_t data_size = 0u; + ProtocolFramePtr frame_ptr = + std::make_shared(connection_id, + PROTOCOL_VERSION_3, + PROTECTION_ON, + FRAME_TYPE_CONTROL, + kControl, + FRAME_DATA_FIRST, + session_id, + data_size, + message_id, + null_data_); + EXPECT_CALL(ssl_context_mock, Decrypt(_, _, _, _)).Times(0); + + protocol_handler_impl->SetTelemetryObserver(&telemetry_observer_mock); + EXPECT_CALL(telemetry_observer_mock, StartMessageProcess(message_id, _)) + .WillOnce(NotifyTestAsyncWaiter(waiter)); + times++; + + EXPECT_CALL(session_observer_mock, + ProtocolVersionUsed(connection_id, session_id, An())); + + tm_listener->OnTMMessageReceived(frame_ptr->serializePacket()); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); +} + +TEST_F(ProtocolHandlerImplTest, + DecryptFrame_SSLContextInitNotCompleted_Cancelled) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + AddSession(waiter, times); + AddSecurityManager(); + + const uint8_t data_size = 1u; + const uint8_t data_value = 7u; + ProtocolFramePtr frame_ptr = + std::make_shared(connection_id, + PROTOCOL_VERSION_3, + PROTECTION_ON, + FRAME_TYPE_SINGLE, + kAudio, + FRAME_DATA_SINGLE, + session_id, + data_size, + message_id, + &data_value); + + EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, _)) + .WillOnce(Return(&ssl_context_mock)); + EXPECT_CALL(ssl_context_mock, IsInitCompleted()).WillOnce(Return(false)); + EXPECT_CALL(ssl_context_mock, Decrypt(_, _, _, _)).Times(0); + + protocol_handler_impl->SetTelemetryObserver(&telemetry_observer_mock); + EXPECT_CALL(telemetry_observer_mock, StartMessageProcess(_, _)).Times(0); + + tm_listener->OnTMMessageReceived(frame_ptr->serializePacket()); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); +} + +TEST_F(ProtocolHandlerImplTest, DecryptFrame_DecryptFailed_Cancelled) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + AddSession(waiter, times); + AddSecurityManager(); + + const uint8_t data_size = 1u; + const uint8_t data_value = 7u; + ProtocolFramePtr frame_ptr = + std::make_shared(connection_id, + PROTOCOL_VERSION_3, + PROTECTION_ON, + FRAME_TYPE_SINGLE, + kAudio, + FRAME_DATA_SINGLE, + session_id, + data_size, + message_id, + &data_value); + + EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, _)) + .WillOnce(Return(&ssl_context_mock)); + EXPECT_CALL(ssl_context_mock, IsInitCompleted()).WillOnce(Return(true)); + EXPECT_CALL(ssl_context_mock, Decrypt(_, _, _, _)).WillOnce(Return(false)); + + uint32_t session_message_id; + EXPECT_CALL( + session_observer_mock, + OnSessionEndedCallback( + connection_id, session_id, An(), kRpc, An())) + .WillOnce(DoAll(SaveArgPointee<2>(&session_message_id), + Return(kInvalidSessionId))); + + protocol_handler_impl->SetTelemetryObserver(&telemetry_observer_mock); + EXPECT_CALL(telemetry_observer_mock, StartMessageProcess(_, _)).Times(0); + + tm_listener->OnTMMessageReceived(frame_ptr->serializePacket()); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_EQ(session_message_id, message_id); +} + +TEST_F(ProtocolHandlerImplTest, + DecryptFrame_DecryptSucceeded_ContinueDecrypted) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + AddSession(waiter, times); + AddSecurityManager(); + + const uint8_t data_size = 1u; + const uint8_t data_value = 7u; + ProtocolFramePtr frame_ptr = + std::make_shared(connection_id, + PROTOCOL_VERSION_3, + PROTECTION_ON, + FRAME_TYPE_SINGLE, + kAudio, + FRAME_DATA_SINGLE, + session_id, + data_size, + message_id, + &data_value); + EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, _)) + .WillOnce(Return(&ssl_context_mock)); + EXPECT_CALL(ssl_context_mock, IsInitCompleted()).WillOnce(Return(true)); + + EXPECT_CALL(ssl_context_mock, Decrypt(_, _, _, _)) + .WillOnce(DoAll(SetArgPointee<2>(&data_value), + SetArgPointee<3>(data_size), + Return(true))); + EXPECT_CALL(session_observer_mock, + OnSessionEndedCallback(_, _, An(), _)) + .Times(0); + + connection_handler::SessionTransports st; + st.primary_transport = connection_id; + ON_CALL(connection_handler_mock, GetSessionTransports(session_id)) + .WillByDefault(Return(st)); + + protocol_handler_impl->SetTelemetryObserver(&telemetry_observer_mock); + EXPECT_CALL(telemetry_observer_mock, StartMessageProcess(message_id, _)); + EXPECT_CALL(telemetry_observer_mock, EndMessageProcess(_)); + + tm_listener->OnTMMessageReceived(frame_ptr->serializePacket()); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); +} + +TEST_F(ProtocolHandlerImplTest, SendFrame_EncryptFailed_FAIL) { + auto protocol_handler_impl_as_listener = + static_cast( + protocol_handler_impl.get()); + EXPECT_CALL(transport_manager_mock, SendMessageToDevice(_)).Times(0); + protocol_handler::impl::RawFordMessageToMobile message( + std::make_shared(connection_id, + PROTOCOL_VERSION_3, + PROTECTION_OFF, + FRAME_TYPE_SINGLE, + kRpc, + FRAME_DATA_SINGLE, + session_id, + some_data.size(), + message_id, + some_data.data()), + kFinalMessage); + protocol_handler_impl_as_listener->Handle(message); +} +#endif // ENABLE_SECURITY + +TEST_F(ProtocolHandlerImplTest, SendServiceDataAck_PreVersion5) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + AddSession(waiter, times); + + EXPECT_CALL(session_observer_mock, PairFromKey(connection_key, _, _)) + .WillOnce( + DoAll(SetArgPointee<1>(connection_id), SetArgPointee<2>(session_id))); + EXPECT_CALL(session_observer_mock, + ProtocolVersionUsed(connection_id, _, An())) + .WillRepeatedly( + DoAll(SetArgReferee<2>(PROTOCOL_VERSION_4), Return(true))); + + EXPECT_CALL(transport_manager_mock, + SendMessageToDevice(ExpectedMessage(FRAME_TYPE_CONTROL, + FRAME_DATA_SERVICE_DATA_ACK, + PROTECTION_OFF, + kMobileNav))) + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); + times++; + + protocol_handler_impl->SendFramesNumber(connection_key, 0); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); +} + +TEST_F(ProtocolHandlerImplTest, SendServiceDataAck_AfterVersion5) { + auto waiter = TestAsyncWaiter::createInstance(); + uint32_t times = 0; + + AddSession(waiter, times); + + EXPECT_CALL(session_observer_mock, PairFromKey(connection_key, _, _)) + .WillOnce( + DoAll(SetArgPointee<1>(connection_id), SetArgPointee<2>(session_id))); + EXPECT_CALL(session_observer_mock, + ProtocolVersionUsed(connection_id, _, An())) + .WillRepeatedly( + DoAll(SetArgReferee<2>(PROTOCOL_VERSION_5), Return(true))); + + // It is expected that Service Data ACK is NOT sent for version 5+ + EXPECT_CALL(transport_manager_mock, + SendMessageToDevice(ExpectedMessage(FRAME_TYPE_CONTROL, + FRAME_DATA_SERVICE_DATA_ACK, + PROTECTION_OFF, + kMobileNav))) + .Times(0); + + protocol_handler_impl->SendFramesNumber(connection_key, 0); + + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); +} + +/* + * ProtocolHandler shall send StartServiceNAK with a reason param when starting + * a video/audio service if the service type is disallowed by the settings + */ +TEST_F(ProtocolHandlerImplTest, StartSession_NACKReason_DisallowedBySettings) { + const ServiceType service_type = kMobileNav; + const utils::SemanticVersion min_reason_param_version(5, 3, 0); +#ifdef ENABLE_SECURITY + AddSecurityManager(); EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, service_type)) @@ -4008,6 +5290,7 @@ TEST_F(ProtocolHandlerImplTest, StartSession_NACKReason_DisallowedBySettings) { bson_object_put_string(&bson_nack_params, protocol_handler::strings::reason, const_cast(reason.c_str())); + std::vector nack_params = CreateVectorFromBsonObject(&bson_nack_params); bson_object_deinitialize(&bson_nack_params); @@ -4051,7 +5334,7 @@ TEST_F(ProtocolHandlerImplTest, StartSession_NACKReason_SessionObserverReject) { .WillRepeatedly(ReturnNull()); #endif // ENABLE_SECURITY - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; ServiceType service_type; // Expect verification of allowed transport @@ -4068,6 +5351,14 @@ TEST_F(ProtocolHandlerImplTest, StartSession_NACKReason_SessionObserverReject) { .Times(call_times) .WillRepeatedly(ReturnRef(allowed_transports)); + protocol_handler::SessionContext context = + GetSessionContext(connection_id, + NEW_SESSION_ID, + SESSION_START_REJECT, + service_type, + protocol_handler::HASH_ID_WRONG, + PROTECTION_OFF); + // Expect ConnectionHandler check EXPECT_CALL( session_observer_mock, @@ -4079,20 +5370,19 @@ TEST_F(ProtocolHandlerImplTest, StartSession_NACKReason_SessionObserverReject) { .Times(call_times) . // Return sessions start rejection - WillRepeatedly( - DoAll(NotifyTestAsyncWaiter(&waiter), - SaveArg<2>(&service_type), - InvokeMemberFuncWithArg3( - protocol_handler_impl.get(), - &protocol_handler::ProtocolHandler::NotifySessionStarted, - GetSessionContext(connection_id, - NEW_SESSION_ID, - SESSION_START_REJECT, - service_type, - protocol_handler::HASH_ID_WRONG, - PROTECTION_OFF), - ByRef(empty_rejected_param_), - err_reason))); + WillRepeatedly(DoAll( + NotifyTestAsyncWaiter(waiter), + SaveArg<2>(&service_type), + InvokeMemberFuncWithArg3( + protocol_handler_impl.get(), + static_cast&, + const std::string)>( + &protocol_handler::ProtocolHandler::NotifySessionStarted), + ByRef(context), + ByRef(empty_rejected_param_), + err_reason))); times += call_times; // Expect send NAck @@ -4119,7 +5409,7 @@ TEST_F(ProtocolHandlerImplTest, StartSession_NACKReason_SessionObserverReject) { Eq(nack_params)))) .Times(call_times) - .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); times += call_times; for (const ServiceType& service_type : service_types) { @@ -4130,7 +5420,7 @@ TEST_F(ProtocolHandlerImplTest, StartSession_NACKReason_SessionObserverReject) { PROTOCOL_VERSION_5); } - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } /* @@ -4142,7 +5432,7 @@ TEST_F(ProtocolHandlerImplTest, const utils::SemanticVersion min_reason_param_version(5, 3, 0); std::string err_reason = "Wrong hash_id for session " + std::to_string(session_id); - std::shared_ptr waiter = std::make_shared(); + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; AddSession(waiter, times); @@ -4214,6 +5504,140 @@ TEST_F(ProtocolHandlerImplTest, EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } +TEST_F(ProtocolHandlerImplTest, + StartSessionAck_ProtocolVehicleData_VehicleDataParamsForV5) { + auto waiter = TestAsyncWaiter::createInstance(); + + const size_t maximum_rpc_payload_size = 1500; + EXPECT_CALL(protocol_handler_settings_mock, maximum_rpc_payload_size()) + .WillOnce(Return(maximum_rpc_payload_size)); + InitProtocolHandlerImpl(0u, 0u); + + EXPECT_CALL(protocol_handler_settings_mock, max_supported_protocol_version()) + .WillOnce(Return(PROTOCOL_VERSION_5)); + + std::map vehicle_mapping = { + {protocol_handler::strings::vehicle_make, "TestMake"}, + {protocol_handler::strings::vehicle_model, "TestModel"}, + {protocol_handler::strings::vehicle_model_year, "2021"}, + {protocol_handler::strings::vehicle_trim, "TestTrim"}, + {protocol_handler::strings::vehicle_system_hardware_version, "TestHW"}, + {protocol_handler::strings::vehicle_system_software_version, "TestSW"}}; + + connection_handler::ProtocolVehicleData data{ + vehicle_mapping[protocol_handler::strings::vehicle_make], + vehicle_mapping[protocol_handler::strings::vehicle_model], + vehicle_mapping[protocol_handler::strings::vehicle_model_year], + vehicle_mapping[protocol_handler::strings::vehicle_trim], + vehicle_mapping + [protocol_handler::strings::vehicle_system_software_version], + vehicle_mapping + [protocol_handler::strings::vehicle_system_hardware_version]}; + + EXPECT_CALL(connection_handler_mock, GetProtocolVehicleData(_)) + .WillOnce(DoAll(SetArgReferee<0>(data), Return(true))); + + const uint32_t hash_id = 123456; + char full_version_string[] = "5.4.0"; + + BsonObject expected_obj; + bson_object_initialize_default(&expected_obj); + // mtu + bson_object_put_int64(&expected_obj, + protocol_handler::strings::mtu, + static_cast(maximum_rpc_payload_size)); + // hashId + bson_object_put_int32(&expected_obj, + protocol_handler::strings::hash_id, + static_cast(hash_id)); + // protocolVersion + bson_object_put_string(&expected_obj, + protocol_handler::strings::protocol_version, + full_version_string); + + // vehicle data + const uint16_t max_string_length = 500; + for (auto& data_pair : vehicle_mapping) { + char value_buffer[max_string_length + 1]; // extra byte for NULL symbol + strncpy(value_buffer, data_pair.second.c_str(), sizeof(value_buffer)); + value_buffer[max_string_length] = 0; + + bson_object_put_string( + &expected_obj, data_pair.first.c_str(), value_buffer); + } + + // secondaryTransports + BsonArray secondary_transports; + bson_array_initialize(&secondary_transports, 0); + bson_object_put_array(&expected_obj, + protocol_handler::strings::secondary_transports, + &secondary_transports); + + BsonArray audio_service_transports; + bson_array_initialize(&audio_service_transports, 1); + bson_array_add_int32(&audio_service_transports, 1); + bson_object_put_array(&expected_obj, + protocol_handler::strings::audio_service_transports, + &audio_service_transports); + + BsonArray video_service_transports; + bson_array_initialize(&video_service_transports, 1); + bson_array_add_int32(&video_service_transports, 1); + bson_object_put_array(&expected_obj, + protocol_handler::strings::video_service_transports, + &video_service_transports); + + std::vector expected_param = + CreateVectorFromBsonObject(&expected_obj); + + bson_object_deinitialize(&expected_obj); + + EXPECT_CALL(transport_manager_mock, + SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_ACK, + PROTECTION_OFF, + connection_id, + Eq(expected_param)))) + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); + + connection_handler::SessionTransports dummy_st = {0, 0}; + EXPECT_CALL(connection_handler_mock, + SetSecondaryTransportID(_, kDisabledSecondary)) + .WillOnce(Return(dummy_st)); + EXPECT_CALL(protocol_handler_settings_mock, multiple_transports_enabled()) + .WillRepeatedly(Return(false)); + std::vector empty_vec; + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillRepeatedly(ReturnRef(empty_vec)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillRepeatedly(ReturnRef(empty_vec)); + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillRepeatedly(Return("WEBSOCKET")); + +#ifdef ENABLE_SECURITY + AddSecurityManager(); + + EXPECT_CALL(session_observer_mock, KeyFromPair(connection_id, session_id)) + .WillRepeatedly(Return(connection_key)); + + EXPECT_CALL(session_observer_mock, GetSSLContext(connection_key, kRpc)) + .WillOnce(ReturnNull()); +#endif // ENABLE_SECURITY + + const uint8_t input_protocol_version = 5; + utils::SemanticVersion full_version(5, 4, 0); + + protocol_handler_impl->SendStartSessionAck(connection_id, + session_id, + input_protocol_version, + hash_id, + kRpc, + false /* protection */, + full_version); + + EXPECT_TRUE(waiter->WaitFor(1, kAsyncExpectationsTimeout)); +} + } // namespace protocol_handler_test } // namespace components } // namespace test 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 f170ef90a72..d6658a79bc4 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 @@ -83,6 +83,10 @@ class CryptoManagerSettingsImpl : public CryptoManagerSettings { return profile_.force_unprotected_service(); } + uint32_t security_level() const OVERRIDE { + return profile_.security_level(); + } + private: const profile::Profile& profile_; const std::string certificate_data_; 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 6e5fb08c20a..7cbb19708e8 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 @@ -216,7 +216,7 @@ class SecurityManagerImpl : public SecurityManager, void ProcessFailedPTU() OVERRIDE; -#ifdef EXTERNAL_PROPRIETARY_MODE +#if defined(EXTERNAL_PROPRIETARY_MODE) && defined(ENABLE_SECURITY) /** * @brief ProcessFailedCertDecrypt is called to notify listeners that * certificate decryption failed in the external flow diff --git a/src/components/security_manager/src/crypto_manager_impl.cc b/src/components/security_manager/src/crypto_manager_impl.cc index b4b4d01485b..717991cf5ca 100644 --- a/src/components/security_manager/src/crypto_manager_impl.cc +++ b/src/components/security_manager/src/crypto_manager_impl.cc @@ -36,20 +36,21 @@ #include #include #include - #include + #include #include #include #include -#include "security_manager/security_manager.h" +#include "security_manager/security_manager.h" #include "utils/atomic.h" #include "utils/date_time.h" #include "utils/logger.h" #include "utils/macro.h" #include "utils/scope_guard.h" +#define OPENSSL1_1_VERSION 0x1010000fL #define TLS1_1_MINIMAL_VERSION 0x1000103fL #define CONST_SSL_METHOD_MINIMAL_VERSION 0x00909000L @@ -170,11 +171,17 @@ bool CryptoManagerImpl::Init() { #else SDL_LOG_DEBUG("SSLv3 is used"); method = is_server ? SSLv3_server_method() : SSLv3_client_method(); + SSL_CTX_set_max_proto_version(context_, SSL3_VERSION); break; #endif case TLSv1: SDL_LOG_DEBUG("TLSv1 is used"); +#if OPENSSL_VERSION_NUMBER < OPENSSL1_1_VERSION method = is_server ? TLSv1_server_method() : TLSv1_client_method(); +#else + method = is_server ? TLS_server_method() : TLS_client_method(); + SSL_CTX_set_max_proto_version(context_, TLS1_VERSION); +#endif break; case TLSv1_1: SDL_LOG_DEBUG("TLSv1_1 is used"); @@ -182,8 +189,11 @@ bool CryptoManagerImpl::Init() { SDL_LOG_WARN( "OpenSSL has no TLSv1.1 with version lower 1.0.1, set TLSv1.0"); method = is_server ? TLSv1_server_method() : TLSv1_client_method(); -#else +#elif OPENSSL_VERSION_NUMBER < OPENSSL1_1_VERSION method = is_server ? TLSv1_1_server_method() : TLSv1_1_client_method(); +#else + method = is_server ? TLS_server_method() : TLS_client_method(); + SSL_CTX_set_max_proto_version(context_, TLS1_1_VERSION); #endif break; case TLSv1_2: @@ -192,13 +202,21 @@ bool CryptoManagerImpl::Init() { SDL_LOG_WARN( "OpenSSL has no TLSv1.2 with version lower 1.0.1, set TLSv1.0"); method = is_server ? TLSv1_server_method() : TLSv1_client_method(); -#else +#elif OPENSSL_VERSION_NUMBER < OPENSSL1_1_VERSION method = is_server ? TLSv1_2_server_method() : TLSv1_2_client_method(); +#else + method = is_server ? TLS_server_method() : TLS_client_method(); + SSL_CTX_set_max_proto_version(context_, TLS1_2_VERSION); #endif break; case DTLSv1: SDL_LOG_DEBUG("DTLSv1 is used"); +#if OPENSSL_VERSION_NUMBER < OPENSSL1_1_VERSION method = is_server ? DTLSv1_server_method() : DTLSv1_client_method(); +#else + method = is_server ? DTLS_server_method() : DTLS_client_method(); + SSL_CTX_set_max_proto_version(context_, DTLS1_VERSION); +#endif break; default: SDL_LOG_ERROR("Unknown protocol: " @@ -213,6 +231,7 @@ bool CryptoManagerImpl::Init() { utils::ScopeGuard guard = utils::MakeGuard(free_ctx, &context_); // Disable SSL2 as deprecated + // TLS 1.2 is the max supported TLS version for SDL SSL_CTX_set_options(context_, SSL_OP_NO_SSLv2); SaveCertificateData(get_settings().certificate_data()); @@ -221,14 +240,31 @@ bool CryptoManagerImpl::Init() { SDL_LOG_WARN("Empty ciphers list"); } else { SDL_LOG_DEBUG("Cipher list: " << get_settings().ciphers_list()); + // If using openssl 1.1.1, this method may always return true + // https://github.com/openssl/openssl/issues/7196#issue-359287519 if (!SSL_CTX_set_cipher_list(context_, get_settings().ciphers_list().c_str())) { SDL_LOG_ERROR( "Could not set cipher list: " << get_settings().ciphers_list()); return false; } +#if OPENSSL_VERSION_NUMBER > OPENSSL1_1_VERSION + auto sk = SSL_CTX_get_ciphers(context_); + const char* p; + for (int i = 0; i < sk_SSL_CIPHER_num(sk); i++) { + const SSL_CIPHER* c = sk_SSL_CIPHER_value(sk, i); + p = SSL_CIPHER_get_name(c); + if (p == NULL) + break; + SDL_LOG_DEBUG("Using Cipher: " << p); + } +#endif } +#if OPENSSL_VERSION_NUMBER >= OPENSSL1_1_VERSION + SSL_CTX_set_security_level(context_, get_settings().security_level()); +#endif + if (get_settings().ca_cert_path().empty()) { SDL_LOG_WARN("Setting up empty CA certificate location"); } diff --git a/src/components/security_manager/src/security_manager_impl.cc b/src/components/security_manager/src/security_manager_impl.cc index 1bf10c4f7ce..914d30003ad 100644 --- a/src/components/security_manager/src/security_manager_impl.cc +++ b/src/components/security_manager/src/security_manager_impl.cc @@ -425,7 +425,7 @@ void SecurityManagerImpl::ProcessFailedPTU() { } } -#ifdef EXTERNAL_PROPRIETARY_MODE +#if defined(EXTERNAL_PROPRIETARY_MODE) && defined(ENABLE_SECURITY) void SecurityManagerImpl::ProcessFailedCertDecrypt() { SDL_LOG_AUTO_TRACE(); { diff --git a/src/components/security_manager/src/ssl_context_impl.cc b/src/components/security_manager/src/ssl_context_impl.cc index 5d151e854a8..1c8b009097f 100644 --- a/src/components/security_manager/src/ssl_context_impl.cc +++ b/src/components/security_manager/src/ssl_context_impl.cc @@ -131,6 +131,8 @@ CryptoManagerImpl::SSLContextImpl::create_max_block_sizes() { rc.insert(std::make_pair("AES128-SHA", seed_sha_max_block_size)); rc.insert( std::make_pair("AES256-GCM-SHA384", aes128_gcm_sha256_max_block_size)); + rc.insert(std::make_pair("ECDHE-RSA-AES256-GCM-SHA384", + aes128_gcm_sha256_max_block_size)); rc.insert(std::make_pair("AES256-SHA256", aes128_sha256_max_block_size)); rc.insert(std::make_pair("AES256-SHA", seed_sha_max_block_size)); rc.insert(std::make_pair("CAMELLIA128-SHA", seed_sha_max_block_size)); @@ -522,16 +524,15 @@ bool CryptoManagerImpl::SSLContextImpl::Decrypt(const uint8_t* const in_data, size_t CryptoManagerImpl::SSLContextImpl::get_max_block_size(size_t mtu) const { SDL_LOG_AUTO_TRACE(); + const auto max_allowed_block_size = + mtu > SSL3_RT_MAX_PLAIN_LENGTH ? SSL3_RT_MAX_PLAIN_LENGTH : mtu; 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; + assert(max_allowed_block_size > 90); + return max_allowed_block_size - 90; } - 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); } @@ -588,7 +589,7 @@ void CryptoManagerImpl::SSLContextImpl::ResetConnection() { SSL_shutdown(connection_); } SDL_LOG_DEBUG("SSL connection recreation"); - SSL_CTX* ssl_context = connection_->ctx; + SSL_CTX* ssl_context = SSL_get_SSL_CTX(connection_); SSL_free(connection_); connection_ = SSL_new(ssl_context); if (mode_ == SERVER) { 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 d30fa5ef23e..85e1ad31295 100644 --- a/src/components/security_manager/test/crypto_manager_impl_test.cc +++ b/src/components/security_manager/test/crypto_manager_impl_test.cc @@ -33,6 +33,7 @@ #ifdef __QNXNTO__ #include #else +#include #include #endif //__QNXNTO__ #include @@ -43,6 +44,8 @@ #include "security_manager/crypto_manager_impl.h" #include "security_manager/mock_security_manager_settings.h" +#define OPENSSL1_1_VERSION 0x1010000fL + using ::testing::NiceMock; using ::testing::Return; using ::testing::ReturnRef; @@ -158,6 +161,9 @@ TEST_F(CryptoManagerTest, WrongInit) { EXPECT_FALSE(crypto_manager_->Init()); EXPECT_NE(std::string(), crypto_manager_->LastError()); +#if OPENSSL1_1_VERSION >= OPENSSL_VERSION_NUMBER + // Legacy test, openssl 1.1.1 changed the error behavior of + // SSL_CTX_set_cipher_list EXPECT_CALL(*mock_security_manager_settings_, security_manager_protocol_name()) .WillOnce(Return(security_manager::TLSv1_2)); @@ -167,6 +173,7 @@ TEST_F(CryptoManagerTest, WrongInit) { .WillRepeatedly(ReturnRef(invalid_cipher)); EXPECT_FALSE(crypto_manager_->Init()); EXPECT_NE(std::string(), crypto_manager_->LastError()); +#endif } // #ifndef __QNXNTO__ diff --git a/src/components/security_manager/test/security_manager_test.cc b/src/components/security_manager/test/security_manager_test.cc index 4145334115c..912ffff4c77 100644 --- a/src/components/security_manager/test/security_manager_test.cc +++ b/src/components/security_manager/test/security_manager_test.cc @@ -284,7 +284,7 @@ TEST_F(SecurityManagerTest, SecurityManager_NULLCryptoManager) { uint32_t connection_id = 0; uint8_t session_id = 0; - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); EXPECT_CALL(mock_session_observer, PairFromKey(kKey, _, _)); EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id, An())) @@ -295,14 +295,14 @@ TEST_F(SecurityManagerTest, SecurityManager_NULLCryptoManager) { InternalErrorWithErrId(SecurityManager::ERROR_NOT_SUPPORTED), false, kIsFinal)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); const SecurityQuery::QueryHeader header(SecurityQuery::REQUEST, // It could be any query id SecurityQuery::INVALID_QUERY_ID); const uint8_t data = 0; EmulateMobileMessage(header, &data, 1); - EXPECT_TRUE(waiter.WaitFor(1, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(1, kAsyncExpectationsTimeout)); } /* * Shall skip all OnMobileMessageSent @@ -377,14 +377,14 @@ TEST_F(SecurityManagerTest, GetInvalidQueryId) { uint32_t connection_id = 0; uint8_t session_id = 0; - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; EXPECT_CALL(mock_session_observer, PairFromKey(kKey, _, _)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id, An())) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(true))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); times++; // Expect InternalError with ERROR_ID @@ -394,14 +394,14 @@ TEST_F(SecurityManagerTest, GetInvalidQueryId) { InternalErrorWithErrId(SecurityManager::ERROR_INVALID_QUERY_ID), false, kIsFinal)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; const SecurityQuery::QueryHeader header(SecurityQuery::REQUEST, SecurityQuery::INVALID_QUERY_ID); const uint8_t data = 0; EmulateMobileMessage(header, &data, 1); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); } /* * Shall send Internall Error on call @@ -577,7 +577,7 @@ TEST_F(SecurityManagerTest, ProcessHandshakeData_WrongDataSize) { uint32_t connection_id = 0; uint8_t session_id = 0; - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); EXPECT_CALL(mock_session_observer, PairFromKey(kKey, _, _)); EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id, An())) @@ -590,11 +590,11 @@ TEST_F(SecurityManagerTest, ProcessHandshakeData_WrongDataSize) { InternalErrorWithErrId(SecurityManager::ERROR_INVALID_QUERY_SIZE), false, kIsFinal)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); EmulateMobileMessageHandshake(NULL, 0); - EXPECT_TRUE(waiter.WaitFor(1, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(1, kAsyncExpectationsTimeout)); } /* * Shall send InternallError on @@ -607,14 +607,14 @@ TEST_F(SecurityManagerTest, DISABLED_ProcessHandshakeData_ServiceNotProtected) { uint32_t connection_id = 0; uint8_t session_id = 0; - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; EXPECT_CALL(mock_session_observer, PairFromKey(kKey, _, _)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id, An())) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(true))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); times++; EXPECT_CALL( mock_protocol_handler, @@ -622,24 +622,24 @@ TEST_F(SecurityManagerTest, DISABLED_ProcessHandshakeData_ServiceNotProtected) { InternalErrorWithErrId(SecurityManager::ERROR_SERVICE_NOT_PROTECTED), false, kIsFinal)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); times++; // Expect notifying listeners (unsuccess) EXPECT_CALL(*mock_sm_listener, OnHandshakeDone(kKey, SSLContext::Handshake_Result_Fail)) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(true))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); times++; // Emulate SessionObserver result EXPECT_CALL(mock_session_observer, GetSSLContext(kKey, kControl)) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), ReturnNull())); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), ReturnNull())); times++; const uint8_t data[] = {0x1, 0x2}; EmulateMobileMessageHandshake(data, sizeof(data) / sizeof(data[0])); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); // Listener was destroyed after OnHandshakeDone call mock_sm_listener.release(); @@ -658,16 +658,16 @@ TEST_F(SecurityManagerTest, ProcessHandshakeData_InvalidData) { uint32_t connection_id = 0; uint8_t session_id = 0; - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; EXPECT_CALL(mock_session_observer, PairFromKey(kKey, _, _)) .Times(handshake_emulates) - .WillRepeatedly(NotifyTestAsyncWaiter(&waiter)); + .WillRepeatedly(NotifyTestAsyncWaiter(waiter)); times += handshake_emulates; EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id, An())) .Times(handshake_emulates) - .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(&waiter), Return(true))); + .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); times += handshake_emulates; // Expect InternalError with ERROR_ID @@ -678,12 +678,12 @@ TEST_F(SecurityManagerTest, ProcessHandshakeData_InvalidData) { false, kIsFinal)) .Times(handshake_emulates) - .WillRepeatedly(NotifyTestAsyncWaiter(&waiter)); + .WillRepeatedly(NotifyTestAsyncWaiter(waiter)); times += handshake_emulates; // Expect notifying listeners (unsuccess) EXPECT_CALL(*mock_sm_listener, OnHandshakeDone(kKey, SSLContext::Handshake_Result_Fail)) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(true))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); times++; // Emulate SessionObserver and CryptoManager result @@ -700,19 +700,19 @@ TEST_F(SecurityManagerTest, ProcessHandshakeData_InvalidData) { _)) .WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer), SetArgPointee<3>(handshake_data_out_size), - NotifyTestAsyncWaiter(&waiter), + NotifyTestAsyncWaiter(waiter), Return(SSLContext::Handshake_Result_AbnormalFail))) .WillOnce(DoAll(SetArgPointee<2>((uint8_t*)NULL), SetArgPointee<3>(handshake_data_out_size), - NotifyTestAsyncWaiter(&waiter), + NotifyTestAsyncWaiter(waiter), Return(SSLContext::Handshake_Result_AbnormalFail))) .WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer), SetArgPointee<3>(0), - NotifyTestAsyncWaiter(&waiter), + NotifyTestAsyncWaiter(waiter), Return(SSLContext::Handshake_Result_AbnormalFail))) .WillOnce(DoAll(SetArgPointee<2>((uint8_t*)NULL), SetArgPointee<3>(0), - NotifyTestAsyncWaiter(&waiter), + NotifyTestAsyncWaiter(waiter), Return(SSLContext::Handshake_Result_AbnormalFail))); times += 4; // matches to each single call above @@ -723,7 +723,7 @@ TEST_F(SecurityManagerTest, ProcessHandshakeData_InvalidData) { EmulateMobileMessageHandshake( handshake_data, handshake_data_size, handshake_emulates); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); // Listener was destroyed after OnHandshakeDone call mock_sm_listener.release(); @@ -740,16 +740,16 @@ TEST_F(SecurityManagerTest, ProcessHandshakeData_Answer) { uint32_t connection_id = 0; uint8_t session_id = 0; - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; EXPECT_CALL(mock_session_observer, PairFromKey(kKey, _, _)) .Times(handshake_emulates) - .WillRepeatedly(NotifyTestAsyncWaiter(&waiter)); + .WillRepeatedly(NotifyTestAsyncWaiter(waiter)); times += handshake_emulates; EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id, An())) .Times(handshake_emulates) - .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(&waiter), Return(true))); + .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); times += handshake_emulates; // Get size of raw message after @@ -758,23 +758,23 @@ TEST_F(SecurityManagerTest, ProcessHandshakeData_Answer) { SendMessageToMobileApp( RawMessageEqSize(raw_message_size), false, kIsFinal)) .Times(handshake_emulates) - .WillRepeatedly(NotifyTestAsyncWaiter(&waiter)); + .WillRepeatedly(NotifyTestAsyncWaiter(waiter)); times += handshake_emulates; // Expect notifying listeners (unsuccess) EXPECT_CALL(*mock_sm_listener, OnHandshakeDone(kKey, SSLContext::Handshake_Result_Fail)) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(true))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); times++; // Emulate SessionObserver and CryptoManager result EXPECT_CALL(mock_ssl_context_exists, IsInitCompleted()) .Times(handshake_emulates) - .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(&waiter), Return(false))); + .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(waiter), Return(false))); times += handshake_emulates; EXPECT_CALL(mock_session_observer, GetSSLContext(kKey, kControl)) .Times(handshake_emulates) - .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(&waiter), + .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(waiter), Return(&mock_ssl_context_exists))); times += handshake_emulates; @@ -787,18 +787,18 @@ TEST_F(SecurityManagerTest, ProcessHandshakeData_Answer) { _)) .WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer), SetArgPointee<3>(handshake_data_out_size), - NotifyTestAsyncWaiter(&waiter), + NotifyTestAsyncWaiter(waiter), Return(SSLContext::Handshake_Result_Success))) .WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer), SetArgPointee<3>(handshake_data_out_size), - NotifyTestAsyncWaiter(&waiter), + NotifyTestAsyncWaiter(waiter), Return(SSLContext::Handshake_Result_Fail))); times += 2; // matches to each single call above EmulateMobileMessageHandshake( handshake_data, handshake_data_size, handshake_emulates); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); // Listener was destroyed after OnHandshakeDone call mock_sm_listener.release(); @@ -813,24 +813,24 @@ TEST_F(SecurityManagerTest, ProcessHandshakeData_HandshakeFinished) { // Count handshake calls const int handshake_emulates = 6; - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); uint32_t times = 0; // Expect no errors // Expect notifying listeners (success) EXPECT_CALL(*mock_sm_listener, OnHandshakeDone(kKey, SSLContext::Handshake_Result_Success)) - .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(true))); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); times++; // Emulate SessionObserver and CryptoManager result EXPECT_CALL(mock_session_observer, GetSSLContext(kKey, kControl)) .Times(handshake_emulates) - .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(&waiter), + .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(waiter), Return(&mock_ssl_context_exists))); times += handshake_emulates; EXPECT_CALL(mock_ssl_context_exists, IsInitCompleted()) .Times(handshake_emulates) - .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(&waiter), Return(true))); + .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); times += handshake_emulates; EXPECT_CALL( @@ -843,31 +843,31 @@ TEST_F(SecurityManagerTest, ProcessHandshakeData_HandshakeFinished) { // two states with correct out data WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer), SetArgPointee<3>(handshake_data_out_size), - NotifyTestAsyncWaiter(&waiter), + NotifyTestAsyncWaiter(waiter), Return(SSLContext::Handshake_Result_Success))) .WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer), SetArgPointee<3>(handshake_data_out_size), - NotifyTestAsyncWaiter(&waiter), + NotifyTestAsyncWaiter(waiter), Return(SSLContext::Handshake_Result_Fail))) . // two states with with null pointer data WillOnce(DoAll(SetArgPointee<2>((uint8_t*)NULL), SetArgPointee<3>(handshake_data_out_size), - NotifyTestAsyncWaiter(&waiter), + NotifyTestAsyncWaiter(waiter), Return(SSLContext::Handshake_Result_Success))) .WillOnce(DoAll(SetArgPointee<2>((uint8_t*)NULL), SetArgPointee<3>(handshake_data_out_size), - NotifyTestAsyncWaiter(&waiter), + NotifyTestAsyncWaiter(waiter), Return(SSLContext::Handshake_Result_Fail))) . // two states with with null data size WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer), SetArgPointee<3>(0), - NotifyTestAsyncWaiter(&waiter), + NotifyTestAsyncWaiter(waiter), Return(SSLContext::Handshake_Result_Success))) .WillOnce(DoAll(SetArgPointee<2>(handshake_data_out_pointer), SetArgPointee<3>(0), - NotifyTestAsyncWaiter(&waiter), + NotifyTestAsyncWaiter(waiter), Return(SSLContext::Handshake_Result_Success))); times += 6; // matches to each single call above @@ -880,19 +880,19 @@ TEST_F(SecurityManagerTest, ProcessHandshakeData_HandshakeFinished) { EXPECT_CALL(mock_session_observer, ProtocolVersionUsed(connection_id, session_id, An())) .Times(2) - .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(&waiter), Return(true))); + .WillRepeatedly(DoAll(NotifyTestAsyncWaiter(waiter), Return(true))); times += 2; // matches to the number above EXPECT_CALL(mock_protocol_handler, SendMessageToMobileApp(_, false, kIsFinal)) .Times(2) - .WillRepeatedly(NotifyTestAsyncWaiter(&waiter)); + .WillRepeatedly(NotifyTestAsyncWaiter(waiter)); times += 2; // matches to the number above // Expect NO InternalError with ERROR_ID EmulateMobileMessageHandshake( handshake_data, handshake_data_size, handshake_emulates); - EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(times, kAsyncExpectationsTimeout)); // Listener was destroyed after OnHandshakeDone call mock_sm_listener.release(); diff --git a/src/components/security_manager/test/ssl_certificate_handshake_test.cc b/src/components/security_manager/test/ssl_certificate_handshake_test.cc index 1034bb3c837..d1de81de738 100644 --- a/src/components/security_manager/test/ssl_certificate_handshake_test.cc +++ b/src/components/security_manager/test/ssl_certificate_handshake_test.cc @@ -413,7 +413,7 @@ TEST_P(SSLHandshakeTest, CAVerification_ServerSide) { GTEST_TRACE(HandshakeProcedure_Success()); } -TEST_P(SSLHandshakeTest, CAVerification_ServerSide_NoCACertificate) { +TEST_P(SSLHandshakeTest, DISABLED_CAVerification_ServerSide_NoCACertificate) { ASSERT_TRUE(InitServerManagers( GetParam().server_protocol, "", "ALL", verify_peer, "unex")) << server_manager_->LastError(); diff --git a/src/components/security_manager/test/ssl_context_test.cc b/src/components/security_manager/test/ssl_context_test.cc index e4d6c308bbd..12620a9d4c1 100644 --- a/src/components/security_manager/test/ssl_context_test.cc +++ b/src/components/security_manager/test/ssl_context_test.cc @@ -227,220 +227,6 @@ class SSLTest : public testing::Test { std::string SSLTest::client_certificate_data_base64_; std::string SSLTest::server_certificate_data_base64_; -// StartHandshake() fails when client and server protocols are not TLSv1_2 -class SSLTestParam : public testing::TestWithParam { - protected: - virtual void SetUp() OVERRIDE { - std::ifstream certificate_file("server/spt_credential.p12"); - ASSERT_TRUE(certificate_file.is_open()) - << "Could not open certificate data file"; - - const std::string certificate( - (std::istreambuf_iterator(certificate_file)), - std::istreambuf_iterator()); - certificate_file.close(); - ASSERT_FALSE(certificate.empty()) << "Certificate data file is empty"; - certificate_data_base64_ = certificate; - - mock_crypto_manager_settings_ = std::make_shared< - NiceMock >(); - std::shared_ptr server_crypto( - mock_crypto_manager_settings_); - crypto_manager_ = new security_manager::CryptoManagerImpl(server_crypto); - - SetServerInitialValues(GetParam().server_protocol_, - GetParam().server_ciphers_list_); - - const bool crypto_manager_initialization = crypto_manager_->Init(); - EXPECT_TRUE(crypto_manager_initialization); - - mock_client_manager_settings_ = std::make_shared< - NiceMock >(); - - std::shared_ptr client_crypto( - mock_client_manager_settings_); - client_manager_ = new security_manager::CryptoManagerImpl(client_crypto); - - SetClientInitialValues(GetParam().client_protocol_, - GetParam().client_ciphers_list_); - - const bool client_manager_initialization = client_manager_->Init(); - EXPECT_TRUE(client_manager_initialization); - - server_ctx_ = crypto_manager_->CreateSSLContext(); - client_ctx_ = client_manager_->CreateSSLContext(); - - using custom_str::CustomString; - - server_ctx_->SetHandshakeContext( - security_manager::SSLContext::HandshakeContext(CustomString("SPT"), - CustomString("client"))); - client_ctx_->SetHandshakeContext( - security_manager::SSLContext::HandshakeContext(CustomString("SPT"), - CustomString("server"))); - - kServerBuf = NULL; - kClientBuf = NULL; - server_buf_len = 0u; - client_buf_len = 0u; - } - - void TearDown() OVERRIDE { - crypto_manager_->ReleaseSSLContext(server_ctx_); - client_manager_->ReleaseSSLContext(client_ctx_); - - delete crypto_manager_; - delete client_manager_; - } - - void SetServerInitialValues(security_manager::Protocol protocol, - const std::string& server_ciphers_list) { - ON_CALL(*mock_crypto_manager_settings_, force_unprotected_service()) - .WillByDefault(ReturnRef(forced_unprotected_service_)); - ON_CALL(*mock_crypto_manager_settings_, force_protected_service()) - .WillByDefault(ReturnRef(forced_protected_service_)); - ON_CALL(*mock_crypto_manager_settings_, security_manager_mode()) - .WillByDefault(Return(security_manager::SERVER)); - ON_CALL(*mock_crypto_manager_settings_, security_manager_protocol_name()) - .WillByDefault(Return(protocol)); - ON_CALL(*mock_crypto_manager_settings_, certificate_data()) - .WillByDefault(ReturnRef(certificate_data_base64_)); - ON_CALL(*mock_crypto_manager_settings_, ciphers_list()) - .WillByDefault(ReturnRef(server_ciphers_list)); - ON_CALL(*mock_crypto_manager_settings_, ca_cert_path()) - .WillByDefault(ReturnRef(kCaPath)); - ON_CALL(*mock_crypto_manager_settings_, verify_peer()) - .WillByDefault(Return(false)); - ON_CALL(*mock_crypto_manager_settings_, module_cert_path()) - .WillByDefault(ReturnRef(kServerCertPath)); - ON_CALL(*mock_crypto_manager_settings_, module_key_path()) - .WillByDefault(ReturnRef(kServerPrivateKeyPath)); - } - - void SetClientInitialValues(security_manager::Protocol protocol, - const std::string& client_ciphers_list) { - ON_CALL(*mock_client_manager_settings_, force_unprotected_service()) - .WillByDefault(ReturnRef(forced_unprotected_service_)); - ON_CALL(*mock_client_manager_settings_, force_protected_service()) - .WillByDefault(ReturnRef(forced_protected_service_)); - ON_CALL(*mock_client_manager_settings_, security_manager_mode()) - .WillByDefault(Return(security_manager::CLIENT)); - ON_CALL(*mock_client_manager_settings_, security_manager_protocol_name()) - .WillByDefault(Return(protocol)); - ON_CALL(*mock_client_manager_settings_, certificate_data()) - .WillByDefault(ReturnRef(certificate_data_base64_)); - ON_CALL(*mock_client_manager_settings_, ciphers_list()) - .WillByDefault(ReturnRef(client_ciphers_list)); - ON_CALL(*mock_client_manager_settings_, ca_cert_path()) - .WillByDefault(ReturnRef(kCaPath)); - ON_CALL(*mock_client_manager_settings_, verify_peer()) - .WillByDefault(Return(false)); - ON_CALL(*mock_client_manager_settings_, module_cert_path()) - .WillByDefault(ReturnRef(kClientCertPath)); - ON_CALL(*mock_client_manager_settings_, module_key_path()) - .WillByDefault(ReturnRef(kClientPrivateKeyPath)); - } - - std::shared_ptr > - mock_crypto_manager_settings_; - std::shared_ptr > - mock_client_manager_settings_; - security_manager::CryptoManager* crypto_manager_; - security_manager::CryptoManager* client_manager_; - security_manager::SSLContext* server_ctx_; - security_manager::SSLContext* client_ctx_; - std::string certificate_data_base64_; - const std::vector forced_unprotected_service_; - const std::vector forced_protected_service_; -}; - -class SSLTestForTLS1_2 : public SSLTestParam {}; - -// This case fails starting because we can handshake only with TLSv1_2 protocol. -INSTANTIATE_TEST_CASE_P( - CorrectProtocolAndCiphers, - SSLTestParam, - ::testing::Values(ProtocolAndCipher(security_manager::TLSv1_1, - security_manager::TLSv1, - kFordCipher, - kFordCipher), - ProtocolAndCipher(security_manager::TLSv1_1, - security_manager::TLSv1_1, - kFordCipher, - kFordCipher) -#ifndef OPENSSL_NO_SSL3 - , - ProtocolAndCipher(security_manager::SSLv3, - security_manager::SSLv3, - kFordCipher, - kFordCipher) -#endif - , - ProtocolAndCipher(security_manager::DTLSv1, - security_manager::DTLSv1, - kFordCipher, - kFordCipher))); - -INSTANTIATE_TEST_CASE_P( - IncorrectProtocolAndCiphers, - SSLTestParam, - ::testing::Values(ProtocolAndCipher(security_manager::TLSv1, - security_manager::TLSv1_1, - kFordCipher, - kFordCipher), - ProtocolAndCipher(security_manager::TLSv1_1, - security_manager::TLSv1, - kFordCipher, - kFordCipher), - ProtocolAndCipher(security_manager::TLSv1_2, - security_manager::TLSv1, - kFordCipher, - kFordCipher), - ProtocolAndCipher(security_manager::TLSv1_2, - security_manager::TLSv1_1, - kFordCipher, - kFordCipher) -#ifndef OPENSSL_NO_SSL3 - , - ProtocolAndCipher(security_manager::TLSv1, - security_manager::SSLv3, - kFordCipher, - kFordCipher), - ProtocolAndCipher(security_manager::TLSv1_1, - security_manager::SSLv3, - kFordCipher, - kFordCipher), - ProtocolAndCipher(security_manager::TLSv1, - security_manager::DTLSv1, - kFordCipher, - kFordCipher), - ProtocolAndCipher(security_manager::DTLSv1, - security_manager::TLSv1_1, - kFordCipher, - kFordCipher), - ProtocolAndCipher(security_manager::TLSv1_2, - security_manager::DTLSv1, - kFordCipher, - kFordCipher), - ProtocolAndCipher(security_manager::TLSv1_1, - security_manager::DTLSv1, - kFordCipher, - kFordCipher), - ProtocolAndCipher(security_manager::TLSv1_2, - security_manager::SSLv3, - kFordCipher, - kFordCipher), - ProtocolAndCipher(security_manager::SSLv3, - security_manager::TLSv1, - kFordCipher, - kFordCipher), - ProtocolAndCipher(security_manager::SSLv3, - security_manager::TLSv1_1, - kFordCipher, - kFordCipher) -#endif - )); - TEST_F(SSLTest, OnTSL2Protocol_BrokenHandshake) { ASSERT_EQ(security_manager::SSLContext::Handshake_Result_Success, client_ctx_->StartHandshake(&kClientBuf, &client_buf_len)); @@ -570,58 +356,6 @@ TEST_F(SSLTest, OnTSL2Protocol_EcncryptionFail) { text, text_len, &encrypted_text, &encrypted_text_len)); } -TEST_P(SSLTestParam, ClientAndServerNotTLSv1_2_HandshakeFailed) { - ASSERT_EQ(security_manager::SSLContext::Handshake_Result_AbnormalFail, - client_ctx_->StartHandshake(&kClientBuf, &client_buf_len)); - - EXPECT_TRUE(NULL == kClientBuf); - EXPECT_EQ(0u, client_buf_len); - ASSERT_EQ(security_manager::SSLContext::Handshake_Result_Success, - server_ctx_->DoHandshakeStep( - kClientBuf, client_buf_len, &kServerBuf, &server_buf_len)); - EXPECT_TRUE(NULL == kServerBuf); - EXPECT_EQ(0u, server_buf_len); - - EXPECT_FALSE(server_ctx_->IsInitCompleted()); -} - -INSTANTIATE_TEST_CASE_P( - ServerProtocolTLSv12, - SSLTestForTLS1_2, - ::testing::Values(ProtocolAndCipher(security_manager::TLSv1, - security_manager::TLSv1_2, - kFordCipher, - kFordCipher), - ProtocolAndCipher(security_manager::TLSv1_1, - security_manager::TLSv1_2, - kFordCipher, - kFordCipher) -#ifndef OPENSSL_NO_SSL3 - , - ProtocolAndCipher(security_manager::SSLv3, - security_manager::TLSv1_2, - kFordCipher, - kFordCipher) -#endif - )); - -TEST_P(SSLTestForTLS1_2, HandshakeFailed) { - ASSERT_EQ(security_manager::SSLContext::Handshake_Result_Success, - client_ctx_->StartHandshake(&kClientBuf, &client_buf_len)); - EXPECT_FALSE(NULL == kClientBuf); - ASSERT_LT(0u, client_buf_len); - - ASSERT_EQ(security_manager::SSLContext::Handshake_Result_AbnormalFail, - server_ctx_->DoHandshakeStep( - kClientBuf, client_buf_len, &kServerBuf, &server_buf_len)) - << ERR_reason_error_string(ERR_get_error()); - - EXPECT_TRUE(NULL == kServerBuf); - EXPECT_EQ(0u, server_buf_len); - - EXPECT_FALSE(server_ctx_->IsInitCompleted()); -} - } // namespace ssl_context_test } // namespace components } // namespace test diff --git a/src/components/smart_objects/test/SmartObjectConvertionTime_test.cc b/src/components/smart_objects/test/SmartObjectConvertionTime_test.cc index 1ce383e44d4..2be93ae013e 100644 --- a/src/components/smart_objects/test/SmartObjectConvertionTime_test.cc +++ b/src/components/smart_objects/test/SmartObjectConvertionTime_test.cc @@ -543,6 +543,7 @@ class SmartObjectConvertionTimeTest : public ::testing::Test { }; } // namespace smart_object_test } // namespace components +} // namespace test namespace ns_smart_device_link { namespace ns_smart_objects { 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 768d9ebb544..9bfe05758fc 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 @@ -171,16 +171,16 @@ class BluetoothDeviceScanner : public DeviceScanner { TransportAdapterController* controller_; threads::Thread* thread_; - bool shutdown_requested_; + std::atomic shutdown_requested_; bool ready_; bool device_scan_requested_; sync_primitives::Lock device_scan_requested_lock_; + sync_primitives::Lock terminate_lock_; sync_primitives::ConditionalVariable device_scan_requested_cv_; std::vector paired_devices_; DeviceVector paired_devices_with_sdl_; - DeviceVector found_devices_with_sdl_; /** * @brief UUID of SmartDeviceLink service. 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 76c8ca73cd2..0465effa94b 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 @@ -183,7 +183,6 @@ class WebsocketClientConnection WebsocketClientConnection& handler_; sync_primitives::Lock queue_lock_; sync_primitives::ConditionalVariable queue_new_items_; - std::atomic_bool write_pending_; std::atomic_bool shutdown_; sync_primitives::Lock write_lock_; diff --git a/src/components/transport_manager/include/transport_manager/websocket_server/websocket_device.h b/src/components/transport_manager/include/transport_manager/websocket_server/websocket_device.h index 10c6e54424f..84235eefa42 100644 --- a/src/components/transport_manager/include/transport_manager/websocket_server/websocket_device.h +++ b/src/components/transport_manager/include/transport_manager/websocket_server/websocket_device.h @@ -38,8 +38,10 @@ #ifndef SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_WEBSOCKET_SERVER_WEBSOCKET_DEVICE_H_ #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_WEBSOCKET_SERVER_WEBSOCKET_DEVICE_H_ +#include #include #include + #include "transport_manager/transport_adapter/device.h" namespace transport_manager { diff --git a/src/components/transport_manager/include/transport_manager/websocket_server/websocket_session.h b/src/components/transport_manager/include/transport_manager/websocket_server/websocket_session.h index f1be1a3b541..009d2fe07cb 100644 --- a/src/components/transport_manager/include/transport_manager/websocket_server/websocket_session.h +++ b/src/components/transport_manager/include/transport_manager/websocket_server/websocket_session.h @@ -32,7 +32,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define SRC_COMPONENTS_TRANSPORT_MANAGER_INCLUDE_TRANSPORT_MANAGER_WEBSOCKET_SERVER_WEBSOCKET_SESSION_H_ #include -#include #include #include #include @@ -99,7 +98,6 @@ class WebSocketSession protected: tcp::socket socket_; websocket::stream ws_; - boost::asio::strand strand_; boost::beast::flat_buffer buffer_; DataReceiveCallback data_receive_; DataSendDoneCallback data_send_done_; 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 f152f1f78da..ce0c2900b77 100644 --- a/src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc +++ b/src/components/transport_manager/src/bluetooth/bluetooth_device_scanner.cc @@ -95,10 +95,10 @@ int FindPairedDevs(std::vector* result) { delete[] buffer; buffer = new char[1028]; } - pclose(pipe); + int status = pclose(pipe); SDL_LOG_TRACE("exit with 0"); delete[] buffer; - return 0; + return status; } } // namespace @@ -112,6 +112,7 @@ BluetoothDeviceScanner::BluetoothDeviceScanner( , ready_(true) , device_scan_requested_(false) , device_scan_requested_lock_() + , terminate_lock_() , device_scan_requested_cv_() , auto_repeat_search_(auto_repeat_search) , auto_repeat_pause_sec_(auto_repeat_pause_sec) { @@ -148,6 +149,7 @@ BluetoothDeviceScanner::BluetoothDeviceScanner( , ready_(true) , device_scan_requested_(false) , device_scan_requested_lock_() + , terminate_lock_() , device_scan_requested_cv_() , auto_repeat_search_(auto_repeat_search) , auto_repeat_pause_sec_(auto_repeat_pause_sec) { @@ -173,9 +175,6 @@ void BluetoothDeviceScanner::UpdateTotalDeviceList() { devices.insert(devices.end(), paired_devices_with_sdl_.begin(), paired_devices_with_sdl_.end()); - devices.insert(devices.end(), - found_devices_with_sdl_.begin(), - found_devices_with_sdl_.end()); controller_->SearchDeviceDone(devices); } @@ -212,38 +211,9 @@ void BluetoothDeviceScanner::DoInquiry() { paired_devices_, device_handle, &paired_devices_with_sdl_); UpdateTotalDeviceList(); - SDL_LOG_INFO("Starting hci_inquiry on device " << device_id); - const uint8_t inquiry_time = 8u; // Time unit is 1.28 seconds - const size_t max_devices = 256u; - inquiry_info* inquiry_info_list = new inquiry_info[max_devices]; - - const int number_of_devices = hci_inquiry(device_id, - inquiry_time, - max_devices, - 0, - &inquiry_info_list, - IREQ_CACHE_FLUSH); - - if (number_of_devices >= 0) { - SDL_LOG_INFO("hci_inquiry: found " << number_of_devices << " devices"); - std::vector found_devices(number_of_devices); - for (int i = 0; i < number_of_devices; ++i) { - found_devices[i] = inquiry_info_list[i].bdaddr; - } - found_devices_with_sdl_.clear(); - CheckSDLServiceOnDevices( - found_devices, device_handle, &found_devices_with_sdl_); - } - UpdateTotalDeviceList(); controller_->FindNewApplicationsRequest(); close(device_handle); - delete[] inquiry_info_list; - - if (number_of_devices < 0) { - SDL_LOG_DEBUG("number_of_devices < 0"); - controller_->SearchDeviceFailed(SearchDeviceError()); - } } void BluetoothDeviceScanner::CheckSDLServiceOnDevices( @@ -424,7 +394,10 @@ void BluetoothDeviceScanner::Thread() { if (auto_repeat_search_) { while (!shutdown_requested_) { DoInquiry(); - device_scan_requested_ = false; + { + sync_primitives::AutoLock auto_lock(device_scan_requested_lock_); + device_scan_requested_ = false; + } TimedWaitForDeviceScanRequest(); } } else { // search only on demand @@ -452,12 +425,22 @@ void BluetoothDeviceScanner::TimedWaitForDeviceScanRequest() { return; } + if (shutdown_requested_) { + SDL_LOG_INFO("Bluetooth scanner Condition: shutdown_requested_ == true"); + return; + } + { sync_primitives::AutoLock auto_lock(device_scan_requested_lock_); while (!(device_scan_requested_ || shutdown_requested_)) { + if (!terminate_lock_.Try()) { + // Lock is taken by terminate thread, return + return; + } const sync_primitives::ConditionalVariable::WaitStatus wait_status = device_scan_requested_cv_.WaitFor(auto_lock, auto_repeat_pause_sec_ * 1000); + terminate_lock_.Release(); if (wait_status == sync_primitives::ConditionalVariable::kTimeout) { SDL_LOG_INFO("Bluetooth scanner timeout, performing scan"); device_scan_requested_ = true; @@ -478,13 +461,16 @@ TransportAdapter::Error BluetoothDeviceScanner::Init() { void BluetoothDeviceScanner::Terminate() { SDL_LOG_AUTO_TRACE(); + if (shutdown_requested_) + return; shutdown_requested_ = true; if (thread_) { + device_scan_requested_cv_.NotifyOne(); { sync_primitives::AutoLock auto_lock(device_scan_requested_lock_); device_scan_requested_ = false; - device_scan_requested_cv_.NotifyOne(); } + sync_primitives::AutoLock auto_lock(terminate_lock_); SDL_LOG_INFO("Waiting for bluetooth device scanner thread termination"); thread_->Stop(threads::Thread::kThreadStopDelegate); SDL_LOG_INFO("Bluetooth device scanner thread stopped"); 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 abeb50e798b..88a219f57e9 100644 --- a/src/components/transport_manager/src/bluetooth/bluetooth_transport_adapter.cc +++ b/src/components/transport_manager/src/bluetooth/bluetooth_transport_adapter.cc @@ -58,7 +58,7 @@ BluetoothTransportAdapter::BluetoothTransportAdapter( resumption::LastStateWrapperPtr last_state_wrapper, const TransportManagerSettings& settings) : TransportAdapterImpl( - new BluetoothDeviceScanner(this, true, 0, settings.bluetooth_uuid()), + new BluetoothDeviceScanner(this, true, 15, settings.bluetooth_uuid()), new BluetoothConnectionFactory(this), NULL, last_state_wrapper, 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 b190e73cb62..a84723d2a16 100644 --- a/src/components/transport_manager/src/cloud/websocket_client_connection.cc +++ b/src/components/transport_manager/src/cloud/websocket_client_connection.cc @@ -240,7 +240,7 @@ void WebsocketClientConnection::OnRead(boost::system::error_code ec, if (ec) { std::string str_err = "ErrorMessage: " + ec.message(); SDL_LOG_ERROR(str_err); - ws_.lowest_layer().close(); + boost::beast::get_lowest_layer(ws_).close(); ioc_.stop(); Shutdown(); return; 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 6aaec5d659c..7a440d24290 100644 --- a/src/components/transport_manager/src/tcp/tcp_client_listener.cc +++ b/src/components/transport_manager/src/tcp/tcp_client_listener.cc @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #ifdef __linux__ @@ -50,6 +49,7 @@ #include #include #include +#include #include #endif // __linux__ diff --git a/src/components/transport_manager/src/websocket_server/websocket_secure_session.cc b/src/components/transport_manager/src/websocket_server/websocket_secure_session.cc index a533bdcffc3..699d2757fdc 100644 --- a/src/components/transport_manager/src/websocket_server/websocket_secure_session.cc +++ b/src/components/transport_manager/src/websocket_server/websocket_secure_session.cc @@ -60,11 +60,9 @@ void WebSocketSecureSession::AsyncAccept() { // Perform the SSL handshake WebSocketSecureSession::ws_.next_layer().async_handshake( ssl::stream_base::server, - boost::asio::bind_executor( - WebSocketSecureSession::strand_, - std::bind(&WebSocketSecureSession::AsyncHandshake, - this->shared_from_this(), - std::placeholders::_1))); + std::bind(&WebSocketSecureSession::AsyncHandshake, + this->shared_from_this(), + std::placeholders::_1)); } template diff --git a/src/components/transport_manager/src/websocket_server/websocket_session.cc b/src/components/transport_manager/src/websocket_server/websocket_session.cc index 8a05b9d9aac..1def04d7006 100644 --- a/src/components/transport_manager/src/websocket_server/websocket_session.cc +++ b/src/components/transport_manager/src/websocket_server/websocket_session.cc @@ -48,7 +48,6 @@ WebSocketSession::WebSocketSession( OnIOErrorCallback on_error) : socket_(std::move(socket)) , ws_(socket_) - , strand_(ws_.get_executor()) , data_receive_(data_receive) , data_send_done_(data_send_done) , data_send_failed_(data_send_failed) @@ -67,7 +66,6 @@ WebSocketSession >::WebSocketSession( OnIOErrorCallback on_error) : socket_(std::move(socket)) , ws_(socket_, ctx) - , strand_(ws_.get_executor()) , data_receive_(data_receive) , data_send_done_(data_send_done) , data_send_failed_(data_send_failed) @@ -83,11 +81,9 @@ WebSocketSession::~WebSocketSession() {} template void WebSocketSession::AsyncAccept() { SDL_LOG_AUTO_TRACE(); - ws_.async_accept( - boost::asio::bind_executor(strand_, - std::bind(&WebSocketSession::AsyncRead, - this->shared_from_this(), - std::placeholders::_1))); + ws_.async_accept(std::bind(&WebSocketSession::AsyncRead, + this->shared_from_this(), + std::placeholders::_1)); } template @@ -100,11 +96,10 @@ void WebSocketSession::AsyncRead(boost::system::error_code ec) { } ws_.async_read(buffer_, - boost::asio::bind_executor(strand_, - std::bind(&WebSocketSession::Read, - this->shared_from_this(), - std::placeholders::_1, - std::placeholders::_2))); + std::bind(&WebSocketSession::Read, + this->shared_from_this(), + std::placeholders::_1, + std::placeholders::_2)); } template 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 e29f182059b..d1bbde05a88 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 @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -80,7 +79,6 @@ class WSSession : public std::enable_shared_from_this { websocket::stream ws_; beast::flat_buffer buffer_; - boost::asio::strand strand_; http::request req_; std::set url_routes_; }; diff --git a/src/components/transport_manager/test/include/transport_manager/websocket_server/websocket_sample_client.h b/src/components/transport_manager/test/include/transport_manager/websocket_server/websocket_sample_client.h index 138502e02c5..0a447a118d9 100644 --- a/src/components/transport_manager/test/include/transport_manager/websocket_server/websocket_sample_client.h +++ b/src/components/transport_manager/test/include/transport_manager/websocket_server/websocket_sample_client.h @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include diff --git a/src/components/transport_manager/test/platform_specific/linux/linux_network_interface_listener_test.cc b/src/components/transport_manager/test/platform_specific/linux/linux_network_interface_listener_test.cc index befba30fbd6..73cc8a5e9a9 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 @@ -119,10 +119,10 @@ TEST_F(NetworkInterfaceListenerTest, Start_success) { // after stated, it is expected that the listener notifies current IP address // (if it's available) - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); EXPECT_CALL(mock_tcp_client_listener_, OnIPAddressUpdated(entries[0].ipv4_address, "")) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); EXPECT_TRUE(interface_listener_impl_->Start()); @@ -131,7 +131,7 @@ TEST_F(NetworkInterfaceListenerTest, Start_success) { EXPECT_TRUE(interface_listener_impl_->GetThread()->IsRunning()); - EXPECT_TRUE(waiter.WaitFor(1, kStartNotificationTimeoutMsec)); + EXPECT_TRUE(waiter->WaitFor(1, kStartNotificationTimeoutMsec)); Deinit(); } diff --git a/src/components/transport_manager/test/sample_websocket_server.cc b/src/components/transport_manager/test/sample_websocket_server.cc index 9b0e5b59d5b..bd153adad44 100644 --- a/src/components/transport_manager/test/sample_websocket_server.cc +++ b/src/components/transport_manager/test/sample_websocket_server.cc @@ -42,8 +42,7 @@ void Fail(char const* tag, boost::system::error_code ec) { namespace sample { namespace websocket { -WSSession::WSServer::WSServer(tcp::socket&& socket) - : ws_(std::move(socket)), strand_(ws_.get_executor()) {} +WSSession::WSServer::WSServer(tcp::socket&& socket) : ws_(std::move(socket)) {} void WSSession::WSServer::AddURLRoute(const std::string& target) { url_routes_.insert(ParseRouteFromTarget(target)); @@ -76,10 +75,8 @@ void WSSession::WSServer::OnWebsocketHandshake( // Accept the websocket handshake ws_.async_accept( req_, - boost::asio::bind_executor(strand_, - std::bind(&WSServer::OnAccept, - shared_from_this(), - std::placeholders::_1))); + std::bind( + &WSServer::OnAccept, shared_from_this(), std::placeholders::_1)); } } 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 d71db3e7702..e29028b562a 100644 --- a/src/components/transport_manager/test/tcp_client_listener_test.cc +++ b/src/components/transport_manager/test/tcp_client_listener_test.cc @@ -250,7 +250,7 @@ TEST_P(TcpClientListenerTest, ClientConnection) { int s = socket(AF_INET, SOCK_STREAM, 0); EXPECT_TRUE(0 <= s); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); // controller should be notified of AddDevice event DeviceSptr mock_device = std::make_shared( @@ -258,7 +258,7 @@ TEST_P(TcpClientListenerTest, ClientConnection) { EXPECT_CALL(adapter_controller_mock_, AddDevice(_)) .WillOnce(Return(mock_device)); EXPECT_CALL(adapter_controller_mock_, ConnectionCreated(_, _, _)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); // adapter_controller_mock_ may also receive ConnectDone() and // ConnectionFinished() from ThreadedSocketConnection. Ignore them as hey are @@ -273,7 +273,7 @@ TEST_P(TcpClientListenerTest, ClientConnection) { client_addr_len)); // since the connection is handled on another thread, wait for some time - EXPECT_TRUE(waiter.WaitFor(1, kConnectionCreatedTimeoutMsec)); + EXPECT_TRUE(waiter->WaitFor(1, kConnectionCreatedTimeoutMsec)); close(s); 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 227367e7505..52ef63f8741 100644 --- a/src/components/transport_manager/test/transport_manager_impl_test.cc +++ b/src/components/transport_manager/test/transport_manager_impl_test.cc @@ -555,11 +555,11 @@ TEST_F(TransportManagerImplTest, SendMessageToDevice) { // Arrange HandleConnection(); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); EXPECT_CALL(*mock_adapter_, SendData(mac_address_, application_id_, test_message_)) .WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), Return(TransportAdapter::OK))); + DoAll(NotifyTestAsyncWaiter(waiter), Return(TransportAdapter::OK))); #ifdef TELEMETRY_MONITOR EXPECT_CALL(mock_metric_observer_, StartRawMsg(test_message_.get())); @@ -567,7 +567,7 @@ TEST_F(TransportManagerImplTest, SendMessageToDevice) { EXPECT_EQ(E_SUCCESS, tm_.SendMessageToDevice(test_message_)); - EXPECT_TRUE(waiter.WaitFor(1, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(1, kAsyncExpectationsTimeout)); } TEST_F(TransportManagerImplTest, SendMessageToDevice_SendingFailed) { @@ -578,30 +578,30 @@ TEST_F(TransportManagerImplTest, SendMessageToDevice_SendingFailed) { EXPECT_CALL(mock_metric_observer_, StartRawMsg(_)); #endif // TELEMETRY_MONITOR - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); EXPECT_CALL(*mock_adapter_, SendData(mac_address_, application_id_, test_message_)) .WillOnce(Return(TransportAdapter::FAIL)); EXPECT_CALL(*tm_listener_, OnTMMessageSendFailed(_, test_message_)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); EXPECT_EQ(E_SUCCESS, tm_.SendMessageToDevice(test_message_)); #ifdef TELEMETRY_MONITOR EXPECT_CALL(mock_metric_observer_, StopRawMsg(_)).Times(0); #endif // TELEMETRY_MONITOR - EXPECT_TRUE(waiter.WaitFor(1, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(1, kAsyncExpectationsTimeout)); } TEST_F(TransportManagerImplTest, SendMessageToDevice_StartTimeObserver) { // Arrange HandleConnection(); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); EXPECT_CALL(*mock_adapter_, SendData(mac_address_, application_id_, test_message_)) .WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), Return(TransportAdapter::OK))); + DoAll(NotifyTestAsyncWaiter(waiter), Return(TransportAdapter::OK))); #ifdef TELEMETRY_MONITOR EXPECT_CALL(mock_metric_observer_, StartRawMsg(_)); @@ -609,18 +609,18 @@ TEST_F(TransportManagerImplTest, SendMessageToDevice_StartTimeObserver) { EXPECT_EQ(E_SUCCESS, tm_.SendMessageToDevice(test_message_)); - EXPECT_TRUE(waiter.WaitFor(1, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(1, kAsyncExpectationsTimeout)); } TEST_F(TransportManagerImplTest, SendMessageToDevice_SendDone) { // Arrange HandleConnection(); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); EXPECT_CALL(*mock_adapter_, SendData(mac_address_, application_id_, test_message_)) .WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), Return(TransportAdapter::OK))); + DoAll(NotifyTestAsyncWaiter(waiter), Return(TransportAdapter::OK))); #ifdef TELEMETRY_MONITOR EXPECT_CALL(mock_metric_observer_, StartRawMsg(test_message_.get())); @@ -630,7 +630,7 @@ TEST_F(TransportManagerImplTest, SendMessageToDevice_SendDone) { HandleSendDone(); - EXPECT_TRUE(waiter.WaitFor(1, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(1, kAsyncExpectationsTimeout)); } TEST_F( @@ -639,11 +639,11 @@ TEST_F( // Arrange HandleConnection(); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); EXPECT_CALL(*mock_adapter_, SendData(mac_address_, application_id_, test_message_)) .WillOnce( - DoAll(NotifyTestAsyncWaiter(&waiter), Return(TransportAdapter::OK))); + DoAll(NotifyTestAsyncWaiter(waiter), Return(TransportAdapter::OK))); #ifdef TELEMETRY_MONITOR EXPECT_CALL(mock_metric_observer_, StartRawMsg(test_message_.get())); @@ -654,7 +654,7 @@ TEST_F( HandleSendFailed(); - EXPECT_TRUE(waiter.WaitFor(1, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(1, kAsyncExpectationsTimeout)); } TEST_F(TransportManagerImplTest, RemoveDevice_DeviceWasAdded) { @@ -749,7 +749,7 @@ TEST_F(TransportManagerImplTest, UpdateDeviceList_RemoveDevice) { * Tests which check correct handling and receiving events */ TEST_F(TransportManagerImplTest, ReceiveEventFromDevice_OnSearchDeviceDone) { - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); TransportAdapterEvent test_event(EventTypeEnum::ON_SEARCH_DONE, mock_adapter_, mac_address_, @@ -758,15 +758,15 @@ TEST_F(TransportManagerImplTest, ReceiveEventFromDevice_OnSearchDeviceDone) { error_); EXPECT_CALL(*tm_listener_, OnScanDevicesFinished()) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); tm_.ReceiveEventFromDevice(test_event); - EXPECT_TRUE(waiter.WaitFor(1, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(1, kAsyncExpectationsTimeout)); } TEST_F(TransportManagerImplTest, ReceiveEventFromDevice_OnSearchDeviceFail) { - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); TransportAdapterEvent test_event(EventTypeEnum::ON_SEARCH_FAIL, mock_adapter_, mac_address_, @@ -775,11 +775,11 @@ TEST_F(TransportManagerImplTest, ReceiveEventFromDevice_OnSearchDeviceFail) { error_); EXPECT_CALL(*tm_listener_, OnScanDevicesFailed(_)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); tm_.ReceiveEventFromDevice(test_event); - EXPECT_TRUE(waiter.WaitFor(1, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(1, kAsyncExpectationsTimeout)); } TEST_F(TransportManagerImplTest, ReceiveEventFromDevice_DeviceListUpdated) { @@ -793,7 +793,7 @@ TEST_F(TransportManagerImplTest, ReceiveEventFromDevice_DeviceListUpdated) { std::vector vector_dev_info; vector_dev_info.push_back(dev_info_); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); EXPECT_CALL(*mock_adapter_, GetDeviceList()) .Times(AtLeast(1)) .WillRepeatedly(Return(device_list_)); @@ -805,14 +805,14 @@ TEST_F(TransportManagerImplTest, ReceiveEventFromDevice_DeviceListUpdated) { .WillRepeatedly(Return(dev_info_.connection_type())); EXPECT_CALL(*tm_listener_, OnDeviceFound(dev_info_)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); EXPECT_CALL(*tm_listener_, OnDeviceAdded(dev_info_)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); tm_.ReceiveEventFromDevice(test_event); device_list_.pop_back(); - EXPECT_TRUE(waiter.WaitFor(2, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(2, kAsyncExpectationsTimeout)); } TEST_F(TransportManagerImplTest, CheckEvents) { @@ -972,13 +972,13 @@ TEST_F(TransportManagerImplTest, HandleMessage_ConnectionNotExist) { SendData(mac_address_, application_id_, test_message_)) .Times(0); - TestAsyncWaiter waiter; + auto waiter = TestAsyncWaiter::createInstance(); EXPECT_CALL(*tm_listener_, OnTMMessageSendFailed(_, test_message_)) - .WillOnce(NotifyTestAsyncWaiter(&waiter)); + .WillOnce(NotifyTestAsyncWaiter(waiter)); tm_.TestHandle(test_message_); - EXPECT_TRUE(waiter.WaitFor(1, kAsyncExpectationsTimeout)); + EXPECT_TRUE(waiter->WaitFor(1, kAsyncExpectationsTimeout)); } TEST_F(TransportManagerImplTest, SearchDevices_TMIsNotInitialized) { diff --git a/src/components/transport_manager/test/websocket_sample_client/websocket_sample_client.cc b/src/components/transport_manager/test/websocket_sample_client/websocket_sample_client.cc index 6c2ff12bfd6..8cf3cb38f1f 100644 --- a/src/components/transport_manager/test/websocket_sample_client/websocket_sample_client.cc +++ b/src/components/transport_manager/test/websocket_sample_client/websocket_sample_client.cc @@ -113,7 +113,8 @@ bool WSSampleClient::Connect(tcp::resolver::results_type& results) { template <> bool WSSampleClient::Connect(tcp::resolver::results_type& results) { boost::system::error_code ec; - boost::asio::connect(ws_->lowest_layer(), results.begin(), results.end(), ec); + boost::asio::connect( + boost::beast::get_lowest_layer(*ws_), results.begin(), results.end(), ec); if (ec) { return false; } @@ -134,7 +135,7 @@ bool WSSampleClient::Handshake(const std::string& host, template <> void WSSampleClient::Stop() { ioc_.stop(); - ws_->lowest_layer().close(); + boost::beast::get_lowest_layer(*ws_).close(); io_pool_.stop(); io_pool_.join(); @@ -165,7 +166,7 @@ void WSSampleClient::Stop() { ioc_.stop(); ws_->next_layer().next_layer().shutdown( boost::asio::ip::tcp::socket::shutdown_both); - ws_->lowest_layer().close(); + boost::beast::get_lowest_layer(*ws_).close(); io_pool_.stop(); io_pool_.join(); diff --git a/src/components/transport_manager/test/websocket_server_listener_test.cc b/src/components/transport_manager/test/websocket_server_listener_test.cc index 7991c6f1cb3..6e1af1ee1ba 100644 --- a/src/components/transport_manager/test/websocket_server_listener_test.cc +++ b/src/components/transport_manager/test/websocket_server_listener_test.cc @@ -128,6 +128,7 @@ TEST_F(WebSocketListenerTest, StartListening_ClientConnect_SUCCESS) { ws_client->Stop(); } +#ifdef ENABLE_SECURITY TEST_F(WebSocketListenerTest, StartListening_ClientConnectSecure_SUCCESS) { const auto ws_listener = std::make_shared( &mock_ta_controller_, mock_tm_settings_, kNumThreads); @@ -254,6 +255,7 @@ TEST_F(WebSocketListenerTest, StartListening_AcceptorIsOpen_SUCCESS) { EXPECT_EQ(TransportAdapter::Error::OK, ws_listener->StartListening()); ws_client->Stop(); } +#endif } // namespace transport_manager_test } // namespace components diff --git a/src/components/utils/include/utils/convert_utils.h b/src/components/utils/include/utils/convert_utils.h index 0609164a600..ba23b620dc0 100644 --- a/src/components/utils/include/utils/convert_utils.h +++ b/src/components/utils/include/utils/convert_utils.h @@ -35,33 +35,44 @@ #include #include +#include namespace utils { /** - * Convert int64 value to long long int value + * @brief Convert int64 value to long long int value * Using when int64 value should be assign to JSON value + * @param value to be converted + * @return conversion result */ long long int ConvertInt64ToLongLongInt(const int64_t value); /** - * Convert long long int value to int64 value + * @brief Convert long long int value to int64 value + * @param value to be converted + * @return conversion result */ int64_t ConvertLongLongIntToInt64(const long long int value); /** - * Convert uint64 value to unsigned long long int value + * @brief Convert uint64 value to unsigned long long int value * Using when uint64 value should be assign to JSON value + * @param value to be converted + * @return conversion result */ unsigned long long int ConvertUInt64ToLongLongUInt(const uint64_t value); /** - * Convert unsigned long long int value to uint64 value + * @brief Convert unsigned long long int value to uint64 value + * @param value to be converted + * @return conversion result */ uint64_t ConvertLongLongUIntToUInt64(const unsigned long long int value); /** - * Convert one number value to another type value + * @brief Convert one number value to another type value + * @param value to be converted + * @return conversion result */ template OutputType SafeStaticCast(const InputType value) { @@ -72,6 +83,16 @@ OutputType SafeStaticCast(const InputType value) { return static_cast(value); } +/** + * @brief Convert binary data to a string value + * @param data raw binary data + * @param data_size string length. Required to check whether the data is a + * printable string. + * @return conversion result + */ +std::string ConvertBinaryDataToString(const uint8_t* data, + const size_t data_size); + } // namespace utils #endif // SRC_COMPONENTS_UTILS_INCLUDE_UTILS_CONVERT_UTILS_H_ diff --git a/src/components/utils/include/utils/file_system.h b/src/components/utils/include/utils/file_system.h index f06ca15281a..232d9583b16 100644 --- a/src/components/utils/include/utils/file_system.h +++ b/src/components/utils/include/utils/file_system.h @@ -40,6 +40,7 @@ #include #include #include +#include "utils/macro.h" namespace file_system { @@ -256,12 +257,7 @@ bool ReadBinaryFile(const std::string& name, bool ReadFile(const std::string& name, std::string& result); -/** - * @brief Convert special symbols in system path to percent-encoded - * - * @param name path to file - * @return returns converted path. - */ +DEPRECATED const std::string ConvertPathForURL(const std::string& path); /** diff --git a/src/components/utils/src/convert_utils.cc b/src/components/utils/src/convert_utils.cc index 9d903187317..cbe0ffde198 100644 --- a/src/components/utils/src/convert_utils.cc +++ b/src/components/utils/src/convert_utils.cc @@ -34,6 +34,7 @@ #include #include #include +#include #include "utils/macro.h" long long int utils::ConvertInt64ToLongLongInt(const int64_t value) { @@ -70,3 +71,23 @@ uint64_t utils::ConvertLongLongUIntToUInt64( return static_cast(value); } + +std::string utils::ConvertBinaryDataToString(const uint8_t* data, + const size_t data_size) { + if (!data_size) { + return std::string(); + } + + bool is_printable_array = true; + std::locale loc; + const char* text = reinterpret_cast(data); + // Check data for printability + for (size_t i = 0; i < data_size; ++i) { + if (!std::isprint(text[i], loc)) { + is_printable_array = false; + break; + } + } + return is_printable_array ? std::string(text, data_size) + : std::string("is raw data"); +} diff --git a/src/components/utils/src/logger/log4cxxlogger.cc b/src/components/utils/src/logger/log4cxxlogger.cc index 7d43892073d..1e87d8cc537 100644 --- a/src/components/utils/src/logger/log4cxxlogger.cc +++ b/src/components/utils/src/logger/log4cxxlogger.cc @@ -90,6 +90,7 @@ log4cxx::LevelPtr getLogLevel(LogLevel log_level) { return log4cxx::Level::getFatal(); default: assert(false); + return log4cxx::Level::getTrace(); } } diff --git a/src/components/utils/test/convert_utils_test.cc b/src/components/utils/test/convert_utils_test.cc new file mode 100644 index 00000000000..250ea1eab40 --- /dev/null +++ b/src/components/utils/test/convert_utils_test.cc @@ -0,0 +1,85 @@ + +/* + * Copyright (c) 2020, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "utils/convert_utils.h" +#include "gtest/gtest.h" + +namespace test { +namespace components { +namespace utils_test { + +using namespace ::utils; + +TEST(ConvertUtilsTest, ConvertInt64ToLongLongInt_CorrectValue) { + int64_t value_to_convert = 42; + EXPECT_EQ(typeid(long long int), + typeid(ConvertInt64ToLongLongInt(value_to_convert))); +} + +TEST(ConvertUtilsTest, ConvertLongLongIntToInt64_CorrectValue) { + long long int value_to_convert = 42; + EXPECT_EQ(typeid(int64_t), + typeid(ConvertLongLongIntToInt64(value_to_convert))); +} + +TEST(ConvertUtilsTest, ConvertUInt64ToLongLongUInt_CorrectValue) { + uint64_t value_to_convert = 42; + EXPECT_EQ(typeid(unsigned long long int), + typeid(ConvertUInt64ToLongLongUInt(value_to_convert))); +} + +TEST(ConvertUtilsTest, ConvertLongLongUIntToUInt64_CorrectValue) { + unsigned long long int value_to_convert = 42; + EXPECT_EQ(typeid(uint64_t), + typeid(ConvertLongLongUIntToUInt64(value_to_convert))); +} + +TEST(ConvertUtilsTest, ConvertBinaryDataToString_ValidCharacteres_CorrectText) { + const uint8_t data[] = {'s', 'u', 'c', 'c', 'e', 's', 's'}; + const std::string convertion_result = "success"; + const size_t data_size = 7; + EXPECT_EQ(convertion_result, ConvertBinaryDataToString(data, data_size)); +} + +TEST(ConvertUtilsTest, + ConvertBinaryDataToString_NotValidCharacters_CorrectText) { + const size_t data_size = 7; + uint8_t data[data_size]; + data[0] = 0u; + const std::string is_raw_data = "is raw data"; + EXPECT_EQ(is_raw_data, ConvertBinaryDataToString(data, data_size)); +} + +} // namespace utils_test +} // namespace components +} // namespace test diff --git a/src/components/utils/test/file_system_test.cc b/src/components/utils/test/file_system_test.cc index 3d518e599fd..a94392f81c8 100644 --- a/src/components/utils/test/file_system_test.cc +++ b/src/components/utils/test/file_system_test.cc @@ -1113,15 +1113,6 @@ TEST(FileSystemTest, GetAvailableDiskSpace) { EXPECT_FALSE(DirectoryExists("./Test directory")); } -TEST(FileSystemTest, ConvertPathForURL) { - std::string path = "./Test directory"; - EXPECT_NE(path, ConvertPathForURL(path)); - std::string path_brackets = "./Test_directory_with(brackets)"; - EXPECT_NE(path_brackets, ConvertPathForURL(path)); - std::string another_path = "./Test_directory/new_directory_without_spaces"; - EXPECT_EQ(another_path, ConvertPathForURL(another_path)); -} - TEST(FileSystemTest, DirectorySize) { ASSERT_FALSE(DirectoryExists("./Test directory")); CreateDirectory("./Test directory"); diff --git a/src/components/utils/test/policy.sql b/src/components/utils/test/policy.sql index d588d695a65..ed627b5fdca 100644 --- a/src/components/utils/test/policy.sql +++ b/src/components/utils/test/policy.sql @@ -22,6 +22,7 @@ BEGIN TRANSACTION; `ccpu_version` VARCHAR(45), `language` VARCHAR(45), `wers_country_code` VARCHAR(45), + `hardware_version` VARCHAR(45), `pt_exchanged_at_odometer_x` INTEGER NOT NULL DEFAULT 0, `pt_exchanged_x_days_after_epoch` INTEGER NOT NULL DEFAULT 0, `ignition_cycles_since_last_exchange` INTEGER NOT NULL DEFAULT 0, diff --git a/tools/InterfaceGenerator/generator/generators/PolicyTypes.py b/tools/InterfaceGenerator/generator/generators/PolicyTypes.py index 53c3062f30e..116273d82c6 100644 --- a/tools/InterfaceGenerator/generator/generators/PolicyTypes.py +++ b/tools/InterfaceGenerator/generator/generators/PolicyTypes.py @@ -441,7 +441,7 @@ def _gen_comment(self, interface_item_base, use_doxygen=True): is True else u"// {0}\n").format(x) for x in self._normalize_multiline_comments( interface_item_base.description)]) - if description is not u"": + if description != u"": description = u"".join([u" *\n" if use_doxygen is True else u"//\n", description]) @@ -451,7 +451,7 @@ def _gen_comment(self, interface_item_base, use_doxygen=True): self._normalize_multiline_comments( interface_item_base. design_description)]) - if design_description is not u"": + if design_description != u"": design_description = u"".join([u" *\n" if use_doxygen is True else "//\n", design_description]) @@ -460,7 +460,7 @@ def _gen_comment(self, interface_item_base, use_doxygen=True): 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"": + if issues != u"": issues = u"".join([u" *\n" if use_doxygen is True else u"//\n", issues]) @@ -468,7 +468,7 @@ def _gen_comment(self, interface_item_base, use_doxygen=True): True else u"// ToDo: {0}\n").format(x) for x in self._normalize_multiline_comments( interface_item_base.todos)]) - if todos is not u"": + if todos != u"": todos = u"".join([u" *\n" if use_doxygen is True else u"//\n", todos]) @@ -505,7 +505,7 @@ def _indent_code(self, code, indent_level): 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]) + x) if x != u"" else u"\n" for x in code_lines]) @staticmethod def _normalize_multiline_comments(initial_strings): diff --git a/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py b/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py index 73ab03f205e..736a95f7aca 100755 --- a/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py +++ b/tools/InterfaceGenerator/generator/generators/SmartFactoryBase.py @@ -564,6 +564,7 @@ def _gen_struct_impl(self, struct, namespace, class_name): struct_name=struct.name, code=self._indent_code( self._struct_impl_code_tempate.substitute( + struct_name=struct.name, schema_loc_decl=self._gen_schema_loc_decls( struct.members.values(), processed_enums), schema_items_decl=self._gen_schema_items_decls( @@ -758,7 +759,7 @@ def _gen_history_vector_decl(self, name): result_array = [] result_array.append(self._impl_code_shared_ptr_vector_template.substitute(var_name = name)) result = u"\n".join(result_array) - if result is not "": + if result != "": result += u"\n\n" return result @@ -789,7 +790,7 @@ def _gen_function_history_decl(self, member): count += 1 result = u"\n\n".join(result_array) - if result is not "": + if result != "": result += u"\n\n" return result @@ -1415,7 +1416,7 @@ def _gen_comment(self, interface_item_base, use_doxygen=True): is True else u"// {0}\n").format(x) for x in self._normalize_multiline_comments( interface_item_base.description)]) - if description is not u"": + if description != u"": description = u"".join([u" *\n" if use_doxygen is True else u"//\n", description]) @@ -1425,7 +1426,7 @@ def _gen_comment(self, interface_item_base, use_doxygen=True): self._normalize_multiline_comments( interface_item_base. design_description)]) - if design_description is not u"": + if design_description != u"": design_description = u"".join([u" *\n" if use_doxygen is True else "//\n", design_description]) @@ -1434,7 +1435,7 @@ def _gen_comment(self, interface_item_base, use_doxygen=True): 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"": + if issues != u"": issues = u"".join([u" *\n" if use_doxygen is True else u"//\n", issues]) @@ -1442,7 +1443,7 @@ def _gen_comment(self, interface_item_base, use_doxygen=True): True else u"// ToDo: {0}\n").format(x) for x in self._normalize_multiline_comments( interface_item_base.todos)]) - if todos is not u"": + if todos != u"": todos = u"".join([u" *\n" if use_doxygen is True else u"//\n", todos]) @@ -1479,7 +1480,7 @@ def _indent_code(self, code, indent_level): 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]) + x) if x != u"" else u"\n" for x in code_lines]) @staticmethod def _normalize_multiline_comments(initial_strings): @@ -1879,11 +1880,9 @@ def _normalize_multiline_comments(initial_strings): _struct_schema_item_template = string.Template( u'''std::shared_ptr struct_schema_item_${name} = ''' u'''InitStructSchemaItem_${name}(struct_schema_items);\n''' - u'''struct_schema_items.insert(std::make_pair(''' - u'''StructIdentifiers::${name}, struct_schema_item_${name}));\n''' u'''structs_schemes_.insert(std::make_pair(''' u'''StructIdentifiers::${name}, CSmartSchema(''' - u'''struct_schema_item_${name})));''') + u'''struct_schema_item_${name})));\n''') _function_schema_template = string.Template( u'''functions_schemes_.insert(std::make_pair(ns_smart_device_link::''' @@ -1896,17 +1895,21 @@ def _normalize_multiline_comments(initial_strings): _struct_impl_template = string.Template( u'''std::shared_ptr $namespace::$class_name::''' u'''InitStructSchemaItem_${struct_name}(\n''' - u''' const TStructsSchemaItems &struct_schema_items) {\n''' + u''' TStructsSchemaItems &struct_schema_items) {\n''' u'''$code''' u'''}\n''') _struct_impl_code_tempate = string.Template( + u'''Members ''' + u'''schema_members;\n''' + u'''std::shared_ptr struct_schema = CObjectSchemaItem::create(schema_members);\n''' + u'''struct_schema_items.insert(std::make_pair(StructIdentifiers::${struct_name}, CObjectSchemaItem::create(schema_members)));\n''' + u'''struct_schema_items[StructIdentifiers::${struct_name}] = struct_schema;\n\n''' u'''${schema_loc_decl}''' u'''${schema_items_decl}''' - u'''Members ''' - u'''schema_members;\n\n''' u'''${schema_item_fill}''' - u'''return CObjectSchemaItem::create(schema_members);''') + u'''for(auto& member : schema_members) {struct_schema->AddMemberSchemaItem(member.first, member.second);}\n''' + u'''return struct_schema;''') _impl_code_loc_decl_enum_template = string.Template( u'''std::set<${type}::eType> ${var_name};''') @@ -2113,7 +2116,7 @@ def _normalize_multiline_comments(initial_strings): u'''static ''' u'''std::shared_ptr ''' u'''InitStructSchemaItem_${struct_name}(\n''' - u''' const TStructsSchemaItems &struct_schema_items);''') + u''' TStructsSchemaItems &struct_schema_items);''') _class_comment_template = string.Template( u'''/**\n''' diff --git a/tools/Utils/generate_test_certificates.py b/tools/Utils/generate_test_certificates.py index 2c1d2cddbfa..ea37eeb4cc0 100755 --- a/tools/Utils/generate_test_certificates.py +++ b/tools/Utils/generate_test_certificates.py @@ -9,6 +9,7 @@ import os import subprocess import tempfile +import shutil from argparse import ArgumentParser from subprocess import check_call @@ -42,6 +43,22 @@ def gen_root_cert(out_cert_file, key_file, days, answer): """ openssl("req -x509 -new -key", key_file, "-days", days, "-out", out_cert_file, "-subj", answer) +def gen_ca_cert(out_cert_file, key_file, ca_cert_file, ca_key_file, days, answer): + request_file = out_cert_file + ".req" + openssl("req -new -key", key_file, "-days", days, "-out", request_file, "-subj", answer) + + temp_dir = tempfile.mkdtemp() + config_file_path = os.path.join(temp_dir, "ca.conf") + config_file = open(config_file_path, 'w') + config_file.write("""[ v3_intermediate_ca ] + basicConstraints = critical, CA:true\n""") + config_file.close() + + openssl("x509 -hash -req -in", request_file, "-CA", ca_cert_file, "-CAkey", ca_key_file, \ + "-CAcreateserial -out", out_cert_file, "-days", days, "-extfile", config_file_path, "-extensions v3_intermediate_ca") + + shutil.rmtree(temp_dir) + def gen_cert(out_cert_file, key_file, ca_cert_file, ca_key_file, days, answer): """Certificate generator wrap console call @@ -58,7 +75,7 @@ def gen_expire_cert(out_cert_file, key_file, ca_cert_file, ca_key_file, days, an """Expired certificate generator wrap console call 'openssl req -new -key $key_file -days $days -out $out_cert_file -subj $answer' - 'openssl ca -batch -config $config_file_path -in $request_file -out $out_cert_file, + 'openssl ca -batch -config $config_file_path -in $request_file -out $out_cert_file, "-cert", ca_cert_file, "-keyfile", ca_key_file, "-startdate 150101000000Z -enddate 150314092653Z' """ request_file = out_cert_file + ".req" @@ -83,7 +100,7 @@ def gen_expire_cert(out_cert_file, key_file, ca_cert_file, ca_key_file, days, an default_ca = ca_default [ ca_default ] - dir = %s""" % (temp_dir, ) + """ + dir = %s""" % (temp_dir, ) + """ certs = %s""" % (current_dir, ) + """ new_certs_dir = %s""" % (current_dir, ) + """ database = %s""" % (database_file_path, ) + """ @@ -93,7 +110,7 @@ def gen_expire_cert(out_cert_file, key_file, ca_cert_file, ca_key_file, days, an private_key = %s""" % (os.path.abspath(ca_key_file), ) + """ default_days = 365 default_crl_days = 30 - default_md = md5 + default_md = sha256 preserve = no policy = generic_policy [ generic_policy ] @@ -109,6 +126,8 @@ def gen_expire_cert(out_cert_file, key_file, ca_cert_file, ca_key_file, days, an openssl("ca -batch -config", config_file_path, "-in", request_file, "-out", out_cert_file, "-startdate 150101000000Z -enddate 150314092653Z") + shutil.rmtree(temp_dir) + def gen_pkcs12(out, key_file, cert_file, verification_certificate) : """Pem to PKCS#12 standard wrap console call @@ -140,7 +159,7 @@ def answers(name, app_id, country, state, locality, organization, unit, email) : return answer def concat_files(out_file_name, *args) : - print "Concatenate text files", args, "into", out_file_name + print "Concatenate text files", args, "into", out_file_name with open(out_file_name, 'w') as outfile: for fname in args : with open(fname) as infile : @@ -199,14 +218,14 @@ def main(): ford_server_key_file = os.path.join(server_dir, "ford_server.key") ford_server_cert_file = os.path.join(server_dir, "ford_server.crt") gen_rsa_key(ford_server_key_file, 2048) - gen_cert(ford_server_cert_file, ford_server_key_file, server_root_cert_file, server_root_key_file, days, ford_server_answer) + gen_ca_cert(ford_server_cert_file, ford_server_key_file, server_root_cert_file, server_root_key_file, days, ford_server_answer) print print " --== Ford client CA certificate generating ==-- " ford_client_key_file = os.path.join(client_dir, "ford_client.key") ford_client_cert_file = os.path.join(client_dir, "ford_client.crt") gen_rsa_key(ford_client_key_file, 2048) - gen_cert(ford_client_cert_file, ford_client_key_file, client_root_cert_file, client_root_key_file, days, ford_client_answer) + gen_ca_cert(ford_client_cert_file, ford_client_key_file, client_root_cert_file, client_root_key_file, days, ford_client_answer) print print " --== SDL and SPT adjustment ==-- " diff --git a/tools/infrastructure/api_compare.py b/tools/infrastructure/api_compare.py old mode 100644 new mode 100755 index 01291196734..ca1279ab61e --- a/tools/infrastructure/api_compare.py +++ b/tools/infrastructure/api_compare.py @@ -1,4 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- import json import sys @@ -7,11 +8,6 @@ import xml.etree.ElementTree as ElementTree from collections import namedtuple -reload(sys) -# Enable Utf-8 support. Needed if script will be run under Windows -sys.setdefaultencoding('utf-8') - - class colors: """Class defining colorful output. Works under UNIX ONLY as Windows does not support ANSI escape sequences @@ -206,53 +202,53 @@ def print_parameters(common_params, hmi_params, mob_params): """Function which prints parameters in mobile, hmi api and common parameters """ - print "Parameters to check: ", common_params, "\n" + print("Parameters to check: ", common_params, "\n") for param in common_params: mob_items = sorted(mob_params[param].items()) hmi_items = sorted(hmi_params[param].items()) - print colors.UNDERLINE + colors.BOLD + param + colors.ENDC, ":" - print "In Mobile API :\t", dict(mob_items) - print "In HMI API :\t", dict(hmi_items) + print(colors.UNDERLINE + colors.BOLD + param + colors.ENDC, ":") + print("In Mobile API :\t", dict(mob_items)) + print("In HMI API :\t", dict(hmi_items)) def print_full_info(hmi_absent_params, hmi_params, mob_absent_params, mob_params, rpc_name): """Function prints full detailed info about every rpc""" - print "\n" + "---" * 60 + "\n" + print("\n" + "---" * 60 + "\n") rpc_color = colors.BOLD + colors.HEADER - print rpc_color + rpc_name + colors.ENDC - print colors.BOLD + "\nMobile API: " + colors.ENDC - print "Parameters quantity: ", len(mob_params) - print "Parameters list: ", sorted(mob_params.keys()) - print colors.BOLD + "HMI API: " + colors.ENDC - print "Parameters quantity: ", len(hmi_params) - print "Parameters list: ", sorted(hmi_params.keys()) - print "\n" + print(rpc_color + rpc_name + colors.ENDC) + print(colors.BOLD + "\nMobile API: " + colors.ENDC) + print("Parameters quantity: ", len(mob_params)) + print("Parameters list: ", sorted(mob_params.keys())) + print(colors.BOLD + "HMI API: " + colors.ENDC) + print("Parameters quantity: ", len(hmi_params)) + print("Parameters list: ", sorted(hmi_params.keys())) + print("\n") print("{}Parameters absent in Mobile APIs: {}{}". format(colors.WARN, mob_absent_params, colors.ENDC)) print("{}Parameters absent in HMI APIs: {}{}". format(colors.WARN, hmi_absent_params, colors.ENDC)) - print "\n" + print("\n") def console_print(summary_result): """Function which prints summary result to console""" for rpc_name in sorted(summary_result.keys()): - print "\n" + "---" * 60 - print colors.HEADER + rpc_name + colors.ENDC + print("\n" + "---" * 60) + print(colors.HEADER + rpc_name + colors.ENDC) for problematic_item in summary_result[rpc_name]: item = summary_result[rpc_name][problematic_item] if len(item) > 0: - print colors.UNDERLINE + problematic_item + colors.ENDC + print(colors.UNDERLINE + problematic_item + colors.ENDC) if type(item) is not dict: print("{}{}{}".format(colors.WARN, item, colors.ENDC)) elif type(item) is dict: for param in item.keys(): item_print = colors.UNDERLINE + param + colors.ENDC - print "{} {}".format("Parameter name: ", item_print) + print("{} {}".format("Parameter name: ", item_print)) res_val = item[param] for key in res_val: - print key, ":", colors.FAIL, res_val[key], colors.ENDC + print(key, ":", colors.FAIL, res_val[key], colors.ENDC) def print_summary_info(summary_result, args): @@ -260,21 +256,21 @@ def print_summary_info(summary_result, args): Output type depends on command line args """ summary_color = colors.UNDERLINE + colors.BOLD + colors.BLUE - print "\n" - print summary_color, "SUMMARY COMPARISON RESULT:\n", colors.ENDC + print("\n") + print(summary_color, "SUMMARY COMPARISON RESULT:\n", colors.ENDC) if len(summary_result) == 0: - print colors.BOLD + " === NO PROBLEMS FOUND ===" + colors.ENDC + print(colors.BOLD + " === NO PROBLEMS FOUND ===" + colors.ENDC) return if args.output == "console": console_print(summary_result) if args.output == "json": json_summary_result = dict_to_json(summary_result) - print json_summary_result + print(json_summary_result) if args.output == "xml": json_summary_result = dict_to_json(summary_result) temp = json.loads(json_summary_result) xml_summary_result = json_to_xml(temp) - print xml_summary_result + print(xml_summary_result) def handle_absent_params(area, absent_params, rpc_name, summary_result): @@ -365,7 +361,7 @@ def all_compare_rule(mob_param_attributes, hmi_param_attributes): """Function used for all common arrtibutes comparison""" mobile_result = {} hmi_result = {} - attr_names = mob_param_attributes.keys() + hmi_param_attributes.keys() + attr_names = [*mob_param_attributes] + [*hmi_param_attributes] attr_names = set(attr_names) for attr_name in attr_names: mobile_attribute_value = None @@ -393,8 +389,8 @@ def all_compare_rule(mob_param_attributes, hmi_param_attributes): mob_param_attributes["type"] == "String", string_compare_rule), # Comparison rule when attribute "array" = "true" (lambda mob_param_attributes, hmi_param_attributes: - 'array' in mob_param_attributes.keys() + - hmi_param_attributes.keys(), array_compare_rule), + 'array' in [*mob_param_attributes] + + [*hmi_param_attributes], array_compare_rule), # Common comparison function for all attributes (lambda mob_param_attributes, hmi_param_attributes: True, all_compare_rule) diff --git a/tools/infrastructure/format_src.py b/tools/infrastructure/format_src.py deleted file mode 100644 index b7927b27086..00000000000 --- a/tools/infrastructure/format_src.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -""" -Format all sources with clang-format. All *.cc and *h in the src dir -are affected. Excluded from formatting sources in the "3rd_party" and -in the "3rd_party-static" dirs. For the formatting used ".clang-format" -in the project root. -""" - -import os -from utils import setup_working_dir, walk_dir, run_cmd -import re - - -INCLUDE_PATTERNS = ['^.*\.cc$', '^.*\.h$', '^.*\.cpp$', '^.*\.hpp$'] -EXCLUDE_PATTERNS = ['^.*3rd_party.*$'] -FORMAT_CMD = 'clang-format -i -style=file {}' - - -def main(): - ''' Main logic ''' - setup_working_dir() - print 'Current working dir is {}'.format(os.getcwd()) - - def action(file_path): - if re.match('|'.join(INCLUDE_PATTERNS), file_path, re.M | re.I): - if not re.match('|'.join(EXCLUDE_PATTERNS), - file_path, - re.M | re.I): - print 'Formatting file {}'.format(file_path) - run_cmd(FORMAT_CMD.format(file_path)) - walk_dir('src', action) - - -if __name__ == '__main__': - main() diff --git a/tools/infrastructure/install_hooks.py b/tools/infrastructure/install_hooks.py index 6f93e02c413..1e1f63de43e 100644 --- a/tools/infrastructure/install_hooks.py +++ b/tools/infrastructure/install_hooks.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @@ -12,14 +12,14 @@ def uninstall_hooks(hooks_dir): - print 'Deleting existing pre-commit hooks from {}'.format(hooks_dir) + print('Deleting existing pre-commit hooks from {}'.format(hooks_dir)) files = glob.glob(os.path.join(hooks_dir, 'pre-commit*')) for item in files: os.remove(item) def install_hooks(src_dir, dst_dir): - print 'Installing pre-commit hooks' + print('Installing pre-commit hooks') src_files = glob.glob(os.path.join(src_dir, 'pre-commit*')) for item in src_files: shutil.copy(item, dst_dir) @@ -28,7 +28,7 @@ def install_hooks(src_dir, dst_dir): def main(): ''' Main logic ''' setup_working_dir() - print 'Current working dir is {}'.format(os.getcwd()) + print('Current working dir is {}'.format(os.getcwd())) hooks_src_dir = os.path.join( os.getcwd(), 'tools', 'infrastructure', 'git-hooks') hooks_dst_dir = os.path.join(os.getcwd(), '.git', 'hooks') diff --git a/tools/intergen/test/test_hmi_interface.xml b/tools/intergen/test/test_hmi_interface.xml index 7573d35ef94..c5978c543ce 100644 --- a/tools/intergen/test/test_hmi_interface.xml +++ b/tools/intergen/test/test_hmi_interface.xml @@ -456,9 +456,6 @@ Total distance to destination for navigation - - Navigation text for UpdateTurnList. - First line of text for audio pass thru @@ -471,9 +468,6 @@ Footer text for slider - - Text of notification to be displayed on screen. - Primary text for Choice diff --git a/tools/rpc_spec b/tools/rpc_spec index 762489ca140..72632f94694 160000 --- a/tools/rpc_spec +++ b/tools/rpc_spec @@ -1 +1 @@ -Subproject commit 762489ca140f246923e8bb8f54e96364e9d0101d +Subproject commit 72632f946941d63a57ee5e99896e3eae3627f7dd