diff options
author | conlain-k <conlain.k@gmail.com> | 2018-06-18 09:52:53 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-18 09:52:53 -0400 |
commit | a2612198bd29c80f20f2d3ea50d80ea8415bb723 (patch) | |
tree | be9546d7ff8b6a34f99b3d9ee3961a0b5850f62c | |
parent | c78c470b991a38037a4ada48b13cba9b3daf1c44 (diff) | |
parent | 1527db9a68a54e07891ccfad0c2532f0813704d7 (diff) | |
download | sdl_core-a2612198bd29c80f20f2d3ea50d80ea8415bb723.tar.gz |
Merge branch 'develop' into feature/boost_filesystem_implementation
125 files changed, 3459 insertions, 910 deletions
diff --git a/.travis.yml b/.travis.yml index 69db195531..73bbfbeb2a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,53 +13,22 @@ addons: apt: sources: - ubuntu-toolchain-r-test - packages: - - gcc-4.9 - - g++-4.9 - - libssl-dev - - libbluetooth3 - - libbluetooth-dev - - libudev-dev - - libusb-1.0 - - cmake - - html2text - - clang-format-3.6 - - binutils + before_install: - - sudo apt-get -qq update - - sudo apt-get -q -y install bluez-tools sqlite3 libsqlite3-dev automake1.11 - - wget http://archive.ubuntu.com/ubuntu/pool/main/l/lcov/lcov_1.11-3_all.deb - - sudo dpkg -i lcov_1.11-3_all.deb + - sudo apt-get update + - sudo apt-get install libssl-dev libbluetooth3 libbluetooth-dev libudev-dev cmake html2text lcov git cmake automake1.11 build-essential libavahi-client-dev sqlite3 libsqlite3-dev libgtest-dev bluez-tools libpulse-dev libusb-1.0.0-dev cppcheck + - sudo apt-get install -f clang-format-3.6 + script: - - sudo ln -sf /usr/bin/gcov-4.9 /usr/bin/gcov - - bash -e tools/infrastructure/check_style.sh - - echo "Number of processing units available ${PROCESSING_UNITS_COUNT}" - - mkdir build && cd build && cmake ../ -DBUILD_TESTS=ON -DENABLE_GCOV=ON && make install -j${PROCESSING_UNITS_COUNT} - - sudo ldconfig - - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`/bin/lib ; make test - - bash ../tools/infrastructure/show_disabled.sh - - bash -ex ../tools/infrastructure/collect_coverage.sh ./ + - cppcheck --force -isrc/3rd_party -isrc/3rd_party-static --quiet --error-exitcode=1 src + - ./tools/infrastructure/check_style.sh + - mkdir build && cd build + - cmake ../ -DBUILD_TESTS=ON + - make install && sudo ldconfig +after_success: + - make test env: global: - LC_CTYPE=en_US.UTF-8 - CTEST_OUTPUT_ON_FAILURE=TRUE - - CMAKE_CXX_COMPILER=g++-4.9 - - CMAKE_C_COMPILER=gcc-4.9 - LD_LIBRARY_PATH=. - - PROCESSING_UNITS_COUNT=$("nproc") -after_success: - - pwd ; bash <(curl -s https://codecov.io/bash) -f ./coverage/coverage.info || echo "Codecov did not collect coverage reports" -deploy: - provider: releases - api-key: "uw8e4USTAS6c9LFhRMYOvw" - file: - - "coverage_report.tar.gz" - skip_cleanup: true - on: - tags: true -notifications: - email: - - AKutsan@luxoft.com - - NSnitsar@luxoft.com - - MGhiumiusliu@luxoft.com - @@ -1,6 +1,6 @@ [![Slack Status](http://sdlslack.herokuapp.com/badge.svg)](http://slack.smartdevicelink.com) - [![codecov.io](https://codecov.io/github/smartdevicelink/sdl_core/coverage.svg?branch=develop)](https://codecov.io/github/smartdevicelink/sdl_core?branch=develop) +[![Build Status](http://opensdl-jenkins.luxoft.com:8080/buildStatus/icon?job=OpenSDL_Nightly)](http://opensdl-jenkins.luxoft.com:8080/view/All/job/OpenSDL_Nightly/) # SmartDeviceLink (SDL) diff --git a/docs/mainpage.dox b/docs/mainpage.dox index 08ef020594..01b9034151 100644 --- a/docs/mainpage.dox +++ b/docs/mainpage.dox @@ -7,5 +7,6 @@ * * ##Table of contents * - \ref security_manager + * - \ref application_manager */ //----------------------------------------------------------- diff --git a/src/3rd_party/CMakeLists.txt b/src/3rd_party/CMakeLists.txt index 63148eff2b..147ecef743 100644 --- a/src/3rd_party/CMakeLists.txt +++ b/src/3rd_party/CMakeLists.txt @@ -227,7 +227,7 @@ if (HMIADAPTER STREQUAL "messagebroker") SOURCE_DIR ${BOOST_LIB_SOURCE_DIRECTORY} CONFIGURE_COMMAND ./bootstrap.sh --with-libraries=system,filesystem --prefix=${3RD_PARTY_INSTALL_PREFIX} BUILD_COMMAND ./b2 - INSTALL_COMMAND ${BOOST_INSTALL_COMMAND} --with-system --with-filesystem --prefix=${3RD_PARTY_INSTALL_PREFIX} + INSTALL_COMMAND ${BOOST_INSTALL_COMMAND} --with-system --with-filesystem --prefix=${3RD_PARTY_INSTALL_PREFIX} > boost_install.log INSTALL_DIR ${3RD_PARTY_INSTALL_PREFIX} BUILD_IN_SOURCE true ) diff --git a/src/appMain/hmi_capabilities.json b/src/appMain/hmi_capabilities.json index 8b61df1b31..50cb479a74 100755 --- a/src/appMain/hmi_capabilities.json +++ b/src/appMain/hmi_capabilities.json @@ -7,6 +7,7 @@ ], "displayCapabilities": { "displayType": "GEN2_8_DMA", + "displayName": "GENERIC_DISPLAY", "textFields": [{ "name": "mainField1", "characterSet": "TYPE2SET", @@ -178,7 +179,6 @@ ], "imageFields": [{ "name": "softButtonImage", - "imageTypeSupported": [], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -186,7 +186,6 @@ }, { "name": "choiceImage", - "imageTypeSupported": [], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -194,7 +193,6 @@ }, { "name": "choiceSecondaryImage", - "imageTypeSupported": [], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -202,7 +200,6 @@ }, { "name": "menuIcon", - "imageTypeSupported": [], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -210,7 +207,6 @@ }, { "name": "cmdIcon", - "imageTypeSupported": [], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -218,7 +214,6 @@ }, { "name": "appIcon", - "imageTypeSupported": [], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -226,7 +221,6 @@ }, { "name": "graphic", - "imageTypeSupported": [], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -234,7 +228,6 @@ }, { "name": "secondaryGraphic", - "imageTypeSupported": [], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 diff --git a/src/appMain/sdl_preloaded_pt.json b/src/appMain/sdl_preloaded_pt.json index 1b3f2b0ff5..e58021bb08 100644 --- a/src/appMain/sdl_preloaded_pt.json +++ b/src/appMain/sdl_preloaded_pt.json @@ -28,6 +28,7 @@ "notifications_per_minute_by_priority": {
"EMERGENCY": 60,
"NAVIGATION": 15,
+ "PROJECTION": 15,
"VOICECOM": 20,
"COMMUNICATION": 6,
"NORMAL": 4,
@@ -2352,7 +2353,9 @@ "steal_focus": false,
"priority": "NONE",
"default_hmi": "NONE",
- "groups": ["Base-4"]
+ "groups": ["Base-4"],
+ "RequestType": [],
+ "RequestSubType": []
},
"device": {
"keep_context": false,
diff --git a/src/components/application_manager/doc/SDL.SDD.ApplicationManager.dox b/src/components/application_manager/doc/SDL.SDD.ApplicationManager.dox new file mode 100644 index 0000000000..447da51c55 --- /dev/null +++ b/src/components/application_manager/doc/SDL.SDD.ApplicationManager.dox @@ -0,0 +1,76 @@ +/** +\page application_manager Application Manager Detailed Design +## Table of contents +- \subpage application_manager_intoduction +- \subpage application_manager_detail_design + + \ref application_manager_state_controller "2.1 State Controller" +*/ +//----------------------------------------------------------- +/** +\page application_manager_intoduction 1 Introduction +The document is intended to support software developers, +maintenance and integration engineers with sufficient, +detailed information concerning the design, development and +deployment concepts, to accomplish their respective tasks without reliance on the authors. +*/ +//----------------------------------------------------------- +/** +\page application_manager_detail_design 2 Component Detail Design +\anchor application_manager_state_controller +### 2.1 State Controller +While application activating by HMI service new HMI level assigned to its state. +The only one application can exist in the same time with HMI level 'FULL'. +Therefore states of other application with their HMI level should be changed respectively. +State Controller handles properly states of other applications while one of them changing it state. + +The main logic of application HMI Level conflict resolver +If applied HMI state is FULL: + - all NOT audio/video applications becomes BACKGROUND + - all audio/video applications with other application type (navi, vc, media, projection) in FULL becomes LIMMITED + - all applications with same application type becomes BACKGROUND + +If applied HMI state is LIMITED: + - all NOT audio/video applications saves their's HMI states + - all applications with other application types saves their's HMI states + - all applications with same application type becomes BACKGROUND + +If applied HMI state is BACKGROUND: + - all applications will save their's HMI states + +Resolve tables to figure out audio/video streaming state for FULL/LIMITED HMI level. +For example if applied is 'NAVIGATION' and resolve application is 'PROJECTION' then to resolve becomes 'NOT_STREAMABLE'. +According to video resolve table the only one application may be 'STREAMABLE' in the same time. + +Video app resolve table(S --> STREAMABLE, NS --> NOT_STREAMABLE) + +| resolve/applied | NAVIGATION | PROJECTION | Other | +|-----------------|------------|------------|-------| +|NAVIGATION | NS | NS | S | +|PROJECTION | NS | NS | S | +|Other | NS | NS | NS | + +Audio application resolve table(A --> AUDIBLE, NS --> NOT_AUDIBLE) + +| resolve/applied | NAVIGATION | COMMUNICATION | IsMediaApp | Other | +|-----------------|------------|---------------|------------|-------| +|NAVIGATION | NA | A | A | A | +|COMMUNICATION | A | NA | A | A | +|IsMediaApp | A | A | NA | A | +|Other | NA | NA | NA | NA | + +\note +For instance if applied application is 'PROJECTION' & isMedia=true with applied HMI level 'FULL' (STREAMABLE & AUDIBLE) +and application to resolve is 'NAVIGATION' with HMI level 'FULL' or 'LIMITED' STREAMABLE & AUDIBLE) +then to resolve becomes 'LIMITED' (NOT_STREAMABLE & AUDIBLE). +So, the only one application may stream video in the same time. But audio application such types as 'NAVIGATION', 'COMMUNICATION' +may stream audio/video in 'LIMITED' level with application of other types. + +\note +If applied application is 'NAVIGATION' (STREAMABLE & AUDIBLE) and application to resolve is same type +'NAVIGATION' (STREAMABLE & AUDIBLE) then to resolve application becomes BACKGROUND (NOT_STREAMABLE & NOT_AUDIBLE). + +\note +When a 'NAVIGATION' application does not start audio streaming service, media application is AUDIBLE, +When the 'NAVIGATION' application starts streaming service, media application is ATTENUATED if system supports mixing, +otherwise media application is NOT_AUDIBLE +*/
\ No newline at end of file diff --git a/src/components/application_manager/include/application_manager/application.h b/src/components/application_manager/include/application_manager/application.h index 01e3bf6b56..cd3b31ce75 100644 --- a/src/components/application_manager/include/application_manager/application.h +++ b/src/components/application_manager/include/application_manager/application.h @@ -539,6 +539,8 @@ class Application : public virtual InitialApplicationData, virtual const mobile_api::SystemContext::eType system_context() const = 0; virtual const mobile_api::AudioStreamingState::eType audio_streaming_state() const = 0; + virtual const mobile_api::VideoStreamingState::eType video_streaming_state() + const = 0; virtual const std::string& app_icon_path() const = 0; virtual connection_handler::DeviceHandle device() const = 0; @@ -730,6 +732,13 @@ class Application : public virtual InitialApplicationData, virtual bool IsAudioApplication() const = 0; /** + * @brief Check's if it is projection or navigation application + * + * @return true if application is projection or navigation + */ + virtual bool IsVideoApplication() const = 0; + + /** * DEPRECATED * @brief GetDeviceId allows to obtain device id which posseses * by this application. 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 50e0a209cf..e033570435 100644 --- a/src/components/application_manager/include/application_manager/application_impl.h +++ b/src/components/application_manager/include/application_manager/application_impl.h @@ -167,6 +167,8 @@ class ApplicationImpl : public virtual Application, const mobile_api::SystemContext::eType system_context() const; inline const mobile_apis::AudioStreamingState::eType audio_streaming_state() const; + inline const mobile_apis::VideoStreamingState::eType video_streaming_state() + const; const std::string& app_icon_path() const; connection_handler::DeviceHandle device() const; const std::string& mac_address() const OVERRIDE; @@ -263,7 +265,14 @@ class ApplicationImpl : public virtual Application, * * @return true if application is media, voice communication or navigation */ - virtual bool IsAudioApplication() const; + bool IsAudioApplication() const OVERRIDE; + + /** + * @brief Checks whether the application is navigation or projection + * + * @return true if application is navigation or projection + */ + bool IsVideoApplication() const OVERRIDE; /** * @brief SetInitialState sets initial HMI state for application on @@ -542,6 +551,14 @@ ApplicationImpl::audio_streaming_state() const { : AudioStreamingState::INVALID_ENUM; } +const mobile_api::VideoStreamingState::eType +ApplicationImpl::video_streaming_state() const { + using namespace mobile_apis; + const HmiStatePtr hmi_state = CurrentHmiState(); + return hmi_state ? hmi_state->video_streaming_state() + : VideoStreamingState::INVALID_ENUM; +} + bool ApplicationImpl::app_allowed() const { return is_app_allowed_; } 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 286ad87018..30816e0ffa 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 @@ -565,6 +565,7 @@ class ApplicationManagerImpl utils::SharedPtr<Application> app, mobile_apis::HMILevel::eType hmi_level, mobile_apis::AudioStreamingState::eType audio_state, + mobile_apis::VideoStreamingState::eType video_state, mobile_apis::SystemContext::eType system_context) const OVERRIDE; /** @@ -583,39 +584,6 @@ class ApplicationManagerImpl mobile_apis::SystemContext::eType system_context) const OVERRIDE; /** - * @brief SetState set regular audio state - * @param app_id applicatio id - * @param audio_state aaudio streaming state - */ - void SetState(uint32_t app_id, - mobile_apis::AudioStreamingState::eType audio_state) { - ApplicationSharedPtr app = application(app_id); - if (!app) { - LOG4CXX_ERROR(logger_, - "Application with appID=" << app_id << " does not exist"); - return; - } - state_ctrl_.SetRegularState(app, audio_state); - } - - /** - * @brief SetState setup regular hmi state, that will appear if no - * specific events are active - * @param app appication to setup regular State - * @param state state of new regular state - */ - template <bool SendActivateApp> - void SetState(uint32_t app_id, HmiStatePtr new_state) { - ApplicationSharedPtr app = application(app_id); - if (!app) { - LOG4CXX_ERROR(logger_, - "Application with appID=" << app_id << " does not exist"); - return; - } - state_ctrl_.SetRegularState(app, new_state, SendActivateApp); - } - - /** * @brief Checks, if given RPC is allowed at current HMI level for specific * application in policy table * @param app Application @@ -677,117 +645,6 @@ class ApplicationManagerImpl ApplicationConstSharedPtr waiting_app(const uint32_t hmi_id) const; /** - * @brief SetState Change regular audio state - * @param app appication to setup regular State - * @param audio_state of new regular state - */ - template <bool SendActivateApp> - void SetState(uint32_t app_id, mobile_apis::HMILevel::eType hmi_level) { - ApplicationSharedPtr app = application(app_id); - if (!app) { - LOG4CXX_ERROR(logger_, - "Application with appID=" << app_id << " does not exist"); - return; - } - state_ctrl_.SetRegularState(app, hmi_level, SendActivateApp); - } - - /** - * @brief SetState Change regular hmi level and audio state - * @param app appication to setup regular State - * @param hmi_level of new regular state - * @param audio_state of new regular state - * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI - */ - template <bool SendActivateApp> - void SetState(uint32_t app_id, - mobile_apis::HMILevel::eType hmi_level, - mobile_apis::AudioStreamingState::eType audio_state) { - ApplicationSharedPtr app = application(app_id); - if (!app) { - LOG4CXX_ERROR(logger_, - "Application with appID=" << app_id << " does not exist"); - return; - } - state_ctrl_.SetRegularState(app, hmi_level, audio_state, SendActivateApp); - } - - /** - * @brief SetState Change regular hmi level and audio state - * @param app appication to setup regular State - * @param hmi_level of new regular state - * @param audio_state of new regular state - * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI - */ - template <bool SendActivateApp> - void SetState(uint32_t app_id, - mobile_apis::HMILevel::eType hmi_level, - mobile_apis::AudioStreamingState::eType audio_state, - mobile_apis::SystemContext::eType system_context) { - ApplicationSharedPtr app = application(app_id); - if (!app) { - LOG4CXX_ERROR(logger_, - "Application with appID=" << app_id << " does not exist"); - return; - } - state_ctrl_.SetRegularState( - app, hmi_level, audio_state, system_context, SendActivateApp); - } - - /** - * @brief SetState Change regular system context - * @param app appication to setup regular State - * @param system_context of new regular state - */ - void SetState(uint32_t app_id, - mobile_apis::SystemContext::eType system_context) { - ApplicationSharedPtr app = application(app_id); - if (!app) { - LOG4CXX_ERROR(logger_, - "Application with appID=" << app_id << " does not exist"); - return; - } - state_ctrl_.SetRegularState(app, system_context); - } - - /** - * @brief SetState Change regular hmi level - * @param app appication to setup regular State - * @param hmi_level hmi level of new regular state - */ - void SetHmiState(uint32_t app_id, mobile_apis::HMILevel::eType hmi_level) { - ApplicationSharedPtr app = application(app_id); - if (!app) { - LOG4CXX_ERROR(logger_, - "Application with appID=" << app_id << " does not exist"); - return; - } - state_ctrl_.SetRegularState(app, hmi_level); - } - - /** - * @brief SetState Change regular hmi state - * @param app appication to setup regular State - * @param state new regular hmi state - */ - void SetState(uint32_t app_id, HmiStatePtr state) { - ApplicationSharedPtr app = application(app_id); - if (!app) { - LOG4CXX_ERROR(logger_, - "Application with appID=" << app_id << " does not exist"); - return; - } - state_ctrl_.SetRegularState(app, state); - } - - /** - * @brief Checks, if particular state is active - * @param state_id State - * @return True, if state is active, otherwise - false - */ - bool IsStateActive(HmiState::StateID state_id) const; - - /** * @brief Notification from PolicyHandler about PTU. * Compares AppHMIType between saved in app and received from PTU. If they are * different method sends: @@ -1357,6 +1214,9 @@ class ApplicationManagerImpl app_launch::AppLaunchCtrl& app_launch_ctrl() OVERRIDE; + bool IsSOStructValid(const hmi_apis::StructIdentifiers::eType struct_id, + const smart_objects::SmartObject& display_capabilities); + private: /** * @brief PullLanguagesInfo allows to pull information about languages. diff --git a/src/components/application_manager/include/application_manager/commands/mobile/register_app_interface_request.h b/src/components/application_manager/include/application_manager/commands/mobile/register_app_interface_request.h index 5713e2e814..a88789bc73 100644 --- a/src/components/application_manager/include/application_manager/commands/mobile/register_app_interface_request.h +++ b/src/components/application_manager/include/application_manager/commands/mobile/register_app_interface_request.h @@ -210,7 +210,7 @@ class RegisterAppInterfaceRequest : public CommandRequestImpl { private: std::string response_info_; - mobile_apis::Result::eType result_checking_app_hmi_type_; + mobile_apis::Result::eType result_code_; policy::PolicyHandlerInterface& GetPolicyHandler(); DISALLOW_COPY_AND_ASSIGN(RegisterAppInterfaceRequest); diff --git a/src/components/application_manager/include/application_manager/hmi_state.h b/src/components/application_manager/include/application_manager/hmi_state.h index f2d665d998..a22d32920a 100644 --- a/src/components/application_manager/include/application_manager/hmi_state.h +++ b/src/components/application_manager/include/application_manager/hmi_state.h @@ -33,6 +33,7 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_STATE_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_STATE_H_ +#include <iosfwd> #include <list> #include "interfaces/MOBILE_API.h" #include "utils/shared_ptr.h" @@ -53,10 +54,12 @@ typedef utils::SharedPtr<HmiState> HmiStatePtr; * */ class HmiState { + friend std::ostream& operator<<(std::ostream& os, const HmiState& src); + public: /** * @brief The StateID enum describes state of application - * If no events occured STATE_ID_DEFAULT shuld be presented + * If no events occurred STATE_ID_DEFAULT should be presented */ enum StateID { STATE_ID_CURRENT, @@ -66,6 +69,7 @@ class HmiState { STATE_ID_SAFETY_MODE, STATE_ID_VR_SESSION, STATE_ID_TTS_SESSION, + STATE_ID_VIDEO_STREAMING, STATE_ID_NAVI_STREAMING, STATE_ID_DEACTIVATE_HMI, STATE_ID_AUDIO_SOURCE, @@ -154,6 +158,28 @@ class HmiState { } return audio_streaming_state_; } + + /** + * @brief video_streaming_state + * @return return video streaming state member + */ + virtual mobile_apis::VideoStreamingState::eType video_streaming_state() + const { + if (parent_) { + return parent_->video_streaming_state(); + } + return video_streaming_state_; + } + + /** + * @brief set_video_streaming_state set set_video_streaming_state member + * @param video_state video_state to setup + */ + virtual void set_video_streaming_state( + mobile_apis::VideoStreamingState::eType video_state) { + video_streaming_state_ = video_state; + } + /** * @brief set_audio_streaming_state set audio_streaming_state member * @param audio_state audio_state to setup @@ -195,7 +221,7 @@ class HmiState { * @brief set_state_id sets state id * @param state_id state id to setup */ - virtual void set_state_id(StateID state_id) { + void set_state_id(StateID state_id) { state_id_ = state_id; } @@ -206,6 +232,7 @@ class HmiState { HmiStatePtr parent_; mobile_apis::HMILevel::eType hmi_level_; mobile_apis::AudioStreamingState::eType audio_streaming_state_; + mobile_apis::VideoStreamingState::eType video_streaming_state_; mobile_apis::SystemContext::eType system_context_; protected: @@ -266,17 +293,27 @@ class TTSHmiState : public HmiState { }; /** - * @brief The NaviStreamingState class implements logic of NaviStreaming + * @brief The VideoStreamingState class implements logic of video streaming * temporary state */ -class NaviStreamingHmiState : public HmiState { +class VideoStreamingHmiState : public HmiState { + public: + VideoStreamingHmiState(utils::SharedPtr<Application> app, + const ApplicationManager& app_mngr); + + mobile_apis::VideoStreamingState::eType video_streaming_state() + const OVERRIDE; +}; + +/** + * @brief The NaviStreamingHmiState class implements logic of navigation + * streaming temporary state that is more specific than VideoStreamingHmiState + */ +class NaviStreamingHmiState : public VideoStreamingHmiState { public: NaviStreamingHmiState(utils::SharedPtr<Application> app, const ApplicationManager& app_mngr); - DEPRECATED NaviStreamingHmiState(uint32_t app_id, - const ApplicationManager& app_mngr); - mobile_apis::AudioStreamingState::eType audio_streaming_state() const OVERRIDE; }; @@ -316,6 +353,10 @@ class SafetyModeHmiState : public HmiState { const OVERRIDE { return mobile_apis::AudioStreamingState::NOT_AUDIBLE; } + mobile_apis::VideoStreamingState::eType video_streaming_state() + const OVERRIDE { + return mobile_apis::VideoStreamingState::NOT_STREAMABLE; + } }; /** @@ -334,6 +375,10 @@ class DeactivateHMI : public HmiState { const OVERRIDE { return mobile_apis::AudioStreamingState::NOT_AUDIBLE; } + mobile_apis::VideoStreamingState::eType video_streaming_state() + const OVERRIDE { + return mobile_apis::VideoStreamingState::NOT_STREAMABLE; + } }; /** @@ -352,6 +397,10 @@ class AudioSource : public HmiState { const OVERRIDE { return mobile_apis::AudioStreamingState::NOT_AUDIBLE; } + mobile_apis::VideoStreamingState::eType video_streaming_state() + const OVERRIDE { + return mobile_apis::VideoStreamingState::NOT_STREAMABLE; + } }; /** @@ -371,6 +420,28 @@ class EmbeddedNavi : public HmiState { const OVERRIDE { return mobile_apis::AudioStreamingState::NOT_AUDIBLE; } + mobile_apis::VideoStreamingState::eType video_streaming_state() + const OVERRIDE { + return mobile_apis::VideoStreamingState::NOT_STREAMABLE; + } }; -} + +/** + * @brief Outputs StateID to ostream in human readable format + * @param os output stream to insert data to + * @param src StateID value to output + * @return os + */ +std::ostream& operator<<(std::ostream& os, const HmiState::StateID src); + +/** + * @brief Outputs HmiState to ostream in human readable format + * @param os output stream to insert data to + * @param src HmiState value to output + * @return os + */ +std::ostream& operator<<(std::ostream& os, const HmiState& src); + +} // namespace application_manager + #endif // SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_HMI_STATE_H_ 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 b94609c01b..57a2f847bf 100644 --- a/src/components/application_manager/include/application_manager/message_helper.h +++ b/src/components/application_manager/include/application_manager/message_helper.h @@ -549,6 +549,37 @@ class MessageHelper { int32_t result_code); /** + * @brief Get the full file path of an app file + * + * @param file_name The relative path of an application file + * @param app Current application + * @param app_mngr Application manager + * + * @return The full file path of the application file if valid, + * empty string otherwise + */ + static std::string GetAppFilePath(std::string file_name, + ApplicationConstSharedPtr app, + ApplicationManager& app_mngr); + + /** + * @brief Verify that all ttsChunks with FILE type + * in an array include an existing file and set full path + * + * @param tts_chunks SmartObject with an array of TTSChunks + * @param app Current application + * @param app_mngr Application manager + * + * @return FILE_NOT_FOUND if one of the TTSChunks + * included a file which wasn't present on disk, + * SUCCESS otherwise + */ + static mobile_apis::Result::eType VerifyTtsFiles( + smart_objects::SmartObject& tts_chunks, + ApplicationConstSharedPtr app, + ApplicationManager& app_mngr); + + /** * @brief Verify image and add image file full path * and add path, although the image doesn't exist * @param SmartObject with image 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 b4653c6cb2..73a05b370e 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 @@ -487,6 +487,32 @@ class PolicyHandler : public PolicyHandlerInterface, mobile_apis::RequestType::eType type) const OVERRIDE; /** + * @brief Checks if certain request subtype is allowed for application + * @param policy_app_id Unique applicaion id + * @param request_subtype Request subtype + * @return true, if allowed, otherwise - false + */ + bool IsRequestSubTypeAllowed( + const std::string& policy_app_id, + const std::string& request_subtype) const OVERRIDE; + + /** + * @brief Gets application request types state + * @param policy_app_id Unique application id + * @return request types state + */ + RequestType::State GetAppRequestTypeState( + const std::string& policy_app_id) const OVERRIDE; + + /** + * @brief Gets application request subtypes state + * @param policy_app_id Unique application id + * @return request subtypes state + */ + RequestSubType::State GetAppRequestSubTypeState( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Gets application request types * @param policy_app_id Unique application id * @return request types @@ -495,6 +521,14 @@ class PolicyHandler : public PolicyHandlerInterface, const std::string& policy_app_id) const OVERRIDE; /** + * @brief Gets application request subtypes + * @param policy_app_id Unique application id + * @return app request subtypes + */ + const std::vector<std::string> GetAppRequestSubTypes( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Gets vehicle information * @return Structure with vehicle information */ 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 b5bf111449..ce5b68ee3c 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 @@ -164,6 +164,7 @@ extern const char* trigger_source; extern const char* hmi_level; extern const char* activate_app_hmi_level; extern const char* audio_streaming_state; +extern const char* video_streaming_state; extern const char* system_context; extern const char* speech_capabilities; extern const char* vr_capabilities; @@ -187,6 +188,7 @@ extern const char* red; extern const char* green; extern const char* blue; extern const char* display_layout; +extern const char* icon_resumed; // PutFile extern const char* sync_file_name; @@ -195,10 +197,12 @@ extern const char* file_type; extern const char* file_size; extern const char* crc32_check_sum; extern const char* request_type; +extern const char* request_subtype; extern const char* persistent_file; extern const char* file_data; extern const char* space_available; extern const char* image_type; +extern const char* is_template; extern const char* image; extern const char* type; extern const char* system_file; @@ -480,6 +484,7 @@ extern const char* dtc; extern const char* ecu_header; extern const char* image_capabilities; extern const char* display_type; +extern const char* display_name; extern const char* text_fields; extern const char* media_clock_formats; extern const char* graphic_supported; diff --git a/src/components/application_manager/include/application_manager/state_controller_impl.h b/src/components/application_manager/include/application_manager/state_controller_impl.h index 1b2033f5a8..58747fdd6e 100644 --- a/src/components/application_manager/include/application_manager/state_controller_impl.h +++ b/src/components/application_manager/include/application_manager/state_controller_impl.h @@ -32,8 +32,9 @@ #ifndef SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_IMPL_H_ #define SRC_COMPONENTS_APPLICATION_MANAGER_INCLUDE_APPLICATION_MANAGER_STATE_CONTROLLER_IMPL_H_ -#include <list> +#include <list> +#include <map> #include "application_manager/hmi_state.h" #include "application_manager/application.h" #include "application_manager/application_manager.h" @@ -67,12 +68,14 @@ class StateControllerImpl : public event_engine::EventObserver, * @param app appication to setup regular State * @param hmi_level of new regular state * @param audio_state of new regular state + * @paran video_state of new regular state * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */ virtual void SetRegularState( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state, const bool SendActivateApp); /** @@ -91,6 +94,7 @@ class StateControllerImpl : public event_engine::EventObserver, * @param app appication to setup regular State * @param hmi_level of new regular state * @param audio_state of new regular state + * @param video_state of new regular state * @param system_context of new regular state * @param SendActivateApp: if true, ActivateAppRequest will be sent on HMI */ @@ -98,6 +102,7 @@ class StateControllerImpl : public event_engine::EventObserver, ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state, const mobile_apis::SystemContext::eType system_context, const bool SendActivateApp); @@ -114,10 +119,12 @@ class StateControllerImpl : public event_engine::EventObserver, * @brief SetRegularState Change regular audio state * @param app appication to setup regular State * @param audio_state of new regular state + * @param video_state of new regular state */ virtual void SetRegularState( ApplicationSharedPtr app, - const mobile_apis::AudioStreamingState::eType audio_state); + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state); /** * @brief SetRegularState Change regular system context @@ -149,17 +156,19 @@ class StateControllerImpl : public event_engine::EventObserver, const mobile_apis::HMILevel::eType default_level); /** - * @brief OnNaviStreamingStarted process Navi streaming started + * @brief OnVideoStreamingStarted process video streaming started + * @param app projection or navigation application starting streaming */ - virtual void OnNaviStreamingStarted(); + virtual void OnVideoStreamingStarted(ApplicationConstSharedPtr app); /** - * @brief OnNaviStreamingStopped process Navi streaming stopped + * @brief OnVideoStreamingStopped process video streaming stopped + * @param app projection or navigation application stopping streaming */ - virtual void OnNaviStreamingStopped(); + virtual void OnVideoStreamingStopped(ApplicationConstSharedPtr app); /** - * @brief OnStateChanged send HMIStatusNotification if neded + * @brief OnStateChanged send HMIStatusNotification if needed * @param app application * @param old_state state before change * @param new_state state after change @@ -184,11 +193,11 @@ class StateControllerImpl : public event_engine::EventObserver, * Move other application to HmiStates if applied moved to FULL or LIMITED */ struct HmiLevelConflictResolver { - ApplicationSharedPtr applied_; - HmiStatePtr state_; + const ApplicationSharedPtr applied_; + const HmiStatePtr state_; StateControllerImpl* state_ctrl_; - HmiLevelConflictResolver(ApplicationSharedPtr app, - HmiStatePtr state, + HmiLevelConflictResolver(const ApplicationSharedPtr app, + const HmiStatePtr state, StateControllerImpl* state_ctrl) : applied_(app), state_(state), state_ctrl_(state_ctrl) {} void operator()(ApplicationSharedPtr to_resolve); @@ -330,6 +339,7 @@ class StateControllerImpl : public event_engine::EventObserver, DCHECK_OR_RETURN_VOID(old_hmi_state); old_hmi_state->set_hmi_level(cur->hmi_level()); old_hmi_state->set_audio_streaming_state(cur->audio_streaming_state()); + old_hmi_state->set_video_streaming_state(cur->video_streaming_state()); old_hmi_state->set_system_context(cur->system_context()); app->RemoveHMIState(ID); HmiStatePtr new_hmi_state = app->CurrentHmiState(); @@ -353,39 +363,18 @@ class StateControllerImpl : public event_engine::EventObserver, void SetupRegularHmiState(ApplicationSharedPtr app, HmiStatePtr state); /** - * @brief IsSameAppType checks if apps has same types - * @param app1 - * @param app2 - * @return true if aps have same types, otherwise return false - */ - bool IsSameAppType(ApplicationConstSharedPtr app1, - ApplicationConstSharedPtr app2); - - /** * @brief SetupRegularHmiState set regular HMI State without * resolving conflicts and ActivateApp request * @param app application * @param hmi_level of new regular state * @param audio_state of new regular state - * @param system_context of new regular state + * @param video_state of new regular state */ void SetupRegularHmiState( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, - const mobile_apis::SystemContext::eType system_context); - - /** - * @brief SetupRegularHmiState set regular HMI State without - * resolving conflicts and ActivateApp request - * @param app application - * @param hmi_level of new regular state - * @param audio_state of new regular state - */ - void SetupRegularHmiState( - ApplicationSharedPtr app, - const mobile_apis::HMILevel::eType hmi_level, - const mobile_apis::AudioStreamingState::eType audio_state); + const mobile_apis::VideoStreamingState::eType video_state); /** * @brief OnActivateAppResponse calback for activate app response @@ -434,14 +423,32 @@ class StateControllerImpl : public event_engine::EventObserver, HmiStatePtr CreateHmiState(utils::SharedPtr<Application> app, HmiState::StateID state_id) const; + /** + * @brief Determines AudioStreamingState value + * for application with HMI level specified. + * @param app an application to calculate for + * @param hmi_level HMI level + * @return AudioStreamingState value + */ mobile_apis::AudioStreamingState::eType CalcAudioState( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level) const; + /** + * @brief Determines VideoStreamingState value + * for application with HMI level specified. + * @param app an application to calculate for + * @param hmi_level HMI level + * @return VideoStreamingState value + */ + mobile_apis::VideoStreamingState::eType CalcVideoState( + ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType hmi_level) const; + typedef std::list<HmiState::StateID> StateIDList; StateIDList active_states_; mutable sync_primitives::Lock active_states_lock_; - std::map<uint32_t, HmiStatePtr> waiting_for_activate; + std::map<uint32_t, HmiStatePtr> waiting_for_activate_; ApplicationManager& app_mngr_; }; } diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index ac21219d7d..8fb88ad5ff 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -230,7 +230,26 @@ void ApplicationImpl::set_voice_communication_supported( } bool ApplicationImpl::IsAudioApplication() const { - return is_media_ || is_voice_communication_application_ || is_navi_; + const bool is_audio_app = + is_media_application() || is_voice_communication_supported() || is_navi(); + LOG4CXX_DEBUG(logger_, + std::boolalpha << "is audio app --> ((is_media_app: " + << is_media_application() << ")" + << " || (is_voice_communication_app: " + << is_voice_communication_supported() << ")" + << " || (is_navi: " << is_navi() << ")) --> " + << is_audio_app); + return is_audio_app; +} + +bool ApplicationImpl::IsVideoApplication() const { + const bool is_video_app = is_navi() || mobile_projection_enabled(); + LOG4CXX_DEBUG(logger_, + std::boolalpha + << "is video app --> ((is_navi: " << is_navi() << ")" + << " || (mobile_projection: " << mobile_projection_enabled() + << ")) --> " << is_video_app); + return is_video_app; } void ApplicationImpl::SetRegularState(HmiStatePtr state) { diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 248b54fee5..5edd485343 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -549,6 +549,7 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( CreateRegularState(utils::SharedPtr<Application>(application), mobile_apis::HMILevel::INVALID_ENUM, mobile_apis::AudioStreamingState::INVALID_ENUM, + mobile_apis::VideoStreamingState::INVALID_ENUM, mobile_api::SystemContext::SYSCTXT_MAIN); application->SetInitialState(initial_state); @@ -623,6 +624,13 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication( const std::string& bundle_id = app_info[strings::bundle_id].asString(); application->set_bundle_id(bundle_id); } + + const std::string app_icon_dir(settings_.app_icons_folder()); + const std::string full_icon_path(app_icon_dir + "/" + policy_app_id); + if (file_system::FileExists(full_icon_path)) { + application->set_app_icon_path(full_icon_path); + } + PutDriverDistractionMessageToPostponed(application); // Stops timer of saving data to resumption in order to @@ -657,13 +665,18 @@ bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN(app, false); + LOG4CXX_DEBUG(logger_, "Activating application with id:" << app->app_id()); + // remove from resumption if app was activated by user resume_controller().OnAppActivated(app); - HMILevel::eType hmi_level = HMILevel::HMI_FULL; - AudioStreamingState::eType audio_state; - app->IsAudioApplication() ? audio_state = AudioStreamingState::AUDIBLE - : audio_state = AudioStreamingState::NOT_AUDIBLE; - state_ctrl_.SetRegularState(app, hmi_level, audio_state, false); + const HMILevel::eType hmi_level = HMILevel::HMI_FULL; + const AudioStreamingState::eType audio_state = + app->IsAudioApplication() ? AudioStreamingState::AUDIBLE + : AudioStreamingState::NOT_AUDIBLE; + const VideoStreamingState::eType video_state = + app->IsVideoApplication() ? VideoStreamingState::STREAMABLE + : VideoStreamingState::NOT_STREAMABLE; + state_ctrl_.SetRegularState(app, hmi_level, audio_state, video_state, false); return true; } @@ -675,10 +688,10 @@ mobile_api::HMILevel::eType ApplicationManagerImpl::IsHmiLevelFullAllowed( NOTREACHED(); return mobile_api::HMILevel::INVALID_ENUM; } - bool is_audio_app = app->IsAudioApplication(); - bool does_audio_app_with_same_type_exist = + const bool is_audio_app = app->IsAudioApplication(); + const bool does_audio_app_with_same_type_exist = IsAppTypeExistsInFullOrLimited(app); - bool is_active_app_exist = active_application().valid(); + const bool is_active_app_exist = active_application().valid(); mobile_api::HMILevel::eType result = mobile_api::HMILevel::HMI_FULL; if (is_audio_app && does_audio_app_with_same_type_exist) { @@ -840,10 +853,12 @@ HmiStatePtr ApplicationManagerImpl::CreateRegularState( utils::SharedPtr<Application> app, mobile_apis::HMILevel::eType hmi_level, mobile_apis::AudioStreamingState::eType audio_state, + mobile_apis::VideoStreamingState::eType video_state, mobile_apis::SystemContext::eType system_context) const { HmiStatePtr state(new HmiState(app, *this)); state->set_hmi_level(hmi_level); state->set_audio_streaming_state(audio_state); + state->set_video_streaming_state(video_state); state->set_system_context(system_context); return state; } @@ -860,12 +875,6 @@ HmiStatePtr ApplicationManagerImpl::CreateRegularState( return state; } -bool ApplicationManagerImpl::IsStateActive(HmiState::StateID state_id) const { - LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, "Checking for active state id " << state_id); - return state_ctrl_.IsStateActive(state_id); -} - void ApplicationManagerImpl::StartAudioPassThruThread(int32_t session_key, int32_t correlation_id, int32_t max_duration, @@ -3560,7 +3569,6 @@ void ApplicationManagerImpl::ForbidStreaming(uint32_t app_id) { void ApplicationManagerImpl::OnAppStreaming( uint32_t app_id, protocol_handler::ServiceType service_type, bool state) { - using namespace protocol_handler; LOG4CXX_AUTO_TRACE(logger_); ApplicationSharedPtr app = application(app_id); @@ -3573,11 +3581,11 @@ void ApplicationManagerImpl::OnAppStreaming( DCHECK_OR_RETURN_VOID(media_manager_); if (state) { - state_ctrl_.OnNaviStreamingStarted(); + state_ctrl_.OnVideoStreamingStarted(app); media_manager_->StartStreaming(app_id, service_type); } else { media_manager_->StopStreaming(app_id, service_type); - state_ctrl_.OnNaviStreamingStopped(); + state_ctrl_.OnVideoStreamingStarted(app); } } @@ -3738,6 +3746,9 @@ void ApplicationManagerImpl::SendHMIStatusNotification( message[strings::msg_params][strings::audio_streaming_state] = static_cast<int32_t>(app->audio_streaming_state()); + message[strings::msg_params][strings::video_streaming_state] = + static_cast<int32_t>(app->video_streaming_state()); + message[strings::msg_params][strings::system_context] = static_cast<int32_t>(app->system_context()); @@ -4060,6 +4071,8 @@ mobile_apis::AppHMIType::eType ApplicationManagerImpl::StringToAppHMIType( return mobile_apis::AppHMIType::MESSAGING; } else if ("NAVIGATION" == str) { return mobile_apis::AppHMIType::NAVIGATION; + } else if ("PROJECTION" == str) { + return mobile_apis::AppHMIType::PROJECTION; } else if ("INFORMATION" == str) { return mobile_apis::AppHMIType::INFORMATION; } else if ("SOCIAL" == str) { @@ -4456,6 +4469,23 @@ std::vector<std::string> ApplicationManagerImpl::ConvertRejectedParamList( return output; } +bool ApplicationManagerImpl::IsSOStructValid( + const hmi_apis::StructIdentifiers::eType struct_id, + const smart_objects::SmartObject& display_capabilities) { + smart_objects::SmartObject display_capabilities_so = display_capabilities; + if (hmi_so_factory().AttachSchema(struct_id, display_capabilities_so)) { + if (display_capabilities_so.isValid()) { + return true; + } else { + return false; + } + } else { + LOG4CXX_ERROR(logger_, "Could not find struct id: " << struct_id); + return false; + } + return true; +} + #ifdef BUILD_TESTS void ApplicationManagerImpl::AddMockApplication(ApplicationSharedPtr mock_app) { applications_list_lock_.Acquire(); @@ -4523,7 +4553,6 @@ std::vector<std::string> ApplicationManagerImpl::devices( void ApplicationManagerImpl::ChangeAppsHMILevel( uint32_t app_id, mobile_apis::HMILevel::eType level) { - using namespace mobile_apis::HMILevel; LOG4CXX_AUTO_TRACE(logger_); LOG4CXX_DEBUG(logger_, "AppID to change: " << app_id << " -> " << level); ApplicationSharedPtr app = application(app_id); @@ -4531,14 +4560,13 @@ void ApplicationManagerImpl::ChangeAppsHMILevel( LOG4CXX_ERROR(logger_, "There is no app with id: " << app_id); return; } - eType old_level = app->hmi_level(); + const mobile_apis::HMILevel::eType old_level = app->hmi_level(); if (old_level != level) { app->set_hmi_level(level); OnHMILevelChanged(app_id, old_level, level); - plugin_manager_.OnAppHMILevelChanged(app, old_level); } else { - LOG4CXX_WARN(logger_, "Redudant changing HMI level : " << level); + LOG4CXX_WARN(logger_, "Redundant changing HMI level: " << level); } } diff --git a/src/components/application_manager/src/application_state.cc b/src/components/application_manager/src/application_state.cc index 101a565a8e..3f775ee4e2 100644 --- a/src/components/application_manager/src/application_state.cc +++ b/src/components/application_manager/src/application_state.cc @@ -101,7 +101,6 @@ void ApplicationState::RemoveState(HmiState::StateID state) { } HmiStatePtr ApplicationState::GetState(HmiState::StateID state_id) const { - LOG4CXX_AUTO_TRACE(logger_); switch (state_id) { case HmiState::StateID::STATE_ID_REGULAR: LOG4CXX_DEBUG(logger_, "Getting regular state."); diff --git a/src/components/application_manager/src/commands/command_request_impl.cc b/src/components/application_manager/src/commands/command_request_impl.cc index 515d8a998c..527d640c5c 100644 --- a/src/components/application_manager/src/commands/command_request_impl.cc +++ b/src/components/application_manager/src/commands/command_request_impl.cc @@ -39,6 +39,7 @@ #include "application_manager/application_manager.h" #include "application_manager/message_helper.h" #include "smart_objects/smart_object.h" + namespace application_manager { namespace commands { @@ -605,10 +606,8 @@ bool CommandRequestImpl::CheckAllowedParameters() { smart_objects::SmartMap::const_iterator iter_end = s_map.map_end(); for (; iter != iter_end; ++iter) { - if (iter->second.asBool()) { - LOG4CXX_DEBUG(logger_, "Request's param: " << iter->first); - params.insert(iter->first); - } + LOG4CXX_DEBUG(logger_, "Request's param: " << iter->first); + params.insert(iter->first); } mobile_apis::Result::eType check_result = diff --git a/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc index efdfaf8f3e..df9dc01eab 100644 --- a/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_exit_application_notification.cc @@ -105,7 +105,11 @@ void OnExitApplicationNotification::Run() { } application_manager_.state_controller().SetRegularState( - app_impl, HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, false); + app_impl, + HMILevel::HMI_NONE, + AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, + false); } } // namespace commands diff --git a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc index d5767690d7..dee364cb99 100644 --- a/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc +++ b/src/components/application_manager/src/commands/mobile/alert_maneuver_request.cc @@ -92,6 +92,21 @@ void AlertManeuverRequest::Run() { // check TTSChunk parameter if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { + smart_objects::SmartObject& tts_chunks = + (*message_)[strings::msg_params][strings::tts_chunks]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(tts_chunks, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + SendResponse(false, + mobile_apis::Result::FILE_NOT_FOUND, + "One or more files needed for tts_chunks are not present"); + return; + } + if (0 < (*message_)[strings::msg_params][strings::tts_chunks].length()) { pending_requests_.Add(hmi_apis::FunctionID::TTS_Speak); tts_is_ok = true; diff --git a/src/components/application_manager/src/commands/mobile/alert_request.cc b/src/components/application_manager/src/commands/mobile/alert_request.cc index 3c42e43767..e0cbe9e600 100644 --- a/src/components/application_manager/src/commands/mobile/alert_request.cc +++ b/src/components/application_manager/src/commands/mobile/alert_request.cc @@ -281,6 +281,23 @@ bool AlertRequest::Validate(uint32_t app_id) { return false; } + if ((*message_)[strings::msg_params].keyExists(strings::tts_chunks)) { + smart_objects::SmartObject& tts_chunks = + (*message_)[strings::msg_params][strings::tts_chunks]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(tts_chunks, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + SendResponse(false, + mobile_apis::Result::FILE_NOT_FOUND, + "One or more files needed for tts_chunks are not present"); + return false; + } + } + return true; } diff --git a/src/components/application_manager/src/commands/mobile/change_registration_request.cc b/src/components/application_manager/src/commands/mobile/change_registration_request.cc index f55767c723..06027a42db 100644 --- a/src/components/application_manager/src/commands/mobile/change_registration_request.cc +++ b/src/components/application_manager/src/commands/mobile/change_registration_request.cc @@ -178,6 +178,23 @@ void ChangeRegistrationRequest::Run() { return; } + if ((*message_)[strings::msg_params].keyExists(strings::tts_name)) { + smart_objects::SmartObject& tts_name = + (*message_)[strings::msg_params][strings::tts_name]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(tts_name, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + SendResponse(false, + mobile_apis::Result::FILE_NOT_FOUND, + "One or more files needed for tts_name are not present"); + return; + } + } + const HmiInterfaces& hmi_interfaces = application_manager_.hmi_interfaces(); const HmiInterfaces::InterfaceState vr_state = diff --git a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc index c29ff3e2d3..f06012893e 100644 --- a/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc +++ b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc @@ -36,6 +36,7 @@ #include "application_manager/commands/mobile/on_system_request_notification.h" #include "interfaces/MOBILE_API.h" #include "utils/file_system.h" +#include "policy/policy_table/enums.h" #include "application_manager/application_manager.h" #include "application_manager/policies/policy_handler_interface.h" @@ -65,19 +66,40 @@ void OnSystemRequestNotification::Run() { return; } - RequestType::eType request_type = static_cast<RequestType::eType>( - (*message_)[strings::msg_params][strings::request_type].asInt()); + const mobile_apis::RequestType::eType request_type = + static_cast<mobile_apis::RequestType::eType>( + (*message_)[strings::msg_params][strings::request_type].asInt()); const policy::PolicyHandlerInterface& policy_handler = application_manager_.GetPolicyHandler(); + + const std::string stringified_request_type = + rpc::policy_table_interface_base::EnumToJsonString( + static_cast<rpc::policy_table_interface_base::RequestType>( + request_type)); + if (!policy_handler.IsRequestTypeAllowed(app->policy_app_id(), request_type)) { LOG4CXX_WARN(logger_, - "Request type " << request_type + "Request type " << stringified_request_type << " is not allowed by policies"); return; } - if (RequestType::PROPRIETARY == request_type) { + const bool request_subtype_present = + (*message_)[strings::msg_params].keyExists(strings::request_subtype); + if (request_subtype_present) { + const std::string request_subtype = + (*message_)[strings::msg_params][strings::request_subtype].asString(); + if (!policy_handler.IsRequestSubTypeAllowed(app->policy_app_id(), + request_subtype)) { + LOG4CXX_ERROR(logger_, + "Request subtype: " << request_subtype + << " is DISALLOWED by policies"); + return; + } + } + + 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" @@ -97,7 +119,7 @@ void OnSystemRequestNotification::Run() { #endif // PROPRIETARY_MODE (*message_)[strings::msg_params][strings::file_type] = FileType::JSON; - } else if (RequestType::HTTP == request_type) { + } else if (mobile_apis::RequestType::HTTP == request_type) { (*message_)[strings::msg_params][strings::file_type] = FileType::BINARY; if ((*message_)[strings::msg_params].keyExists(strings::url)) { (*message_)[strings::msg_params][strings::timeout] = @@ -183,8 +205,8 @@ size_t OnSystemRequestNotification::ParsePTString( if (pt_string[i] == '\"' || pt_string[i] == '\\') { result += '\\'; } else if (pt_string[i] == '\n') { - result_length--; // contentLength is adjusted when this character is not - // copied to result. + result_length--; // contentLength is adjusted when this character is + // not copied to result. continue; } result += pt_string[i]; diff --git a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc index 20076ac50c..a758f04aac 100644 --- a/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc +++ b/src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc @@ -96,8 +96,24 @@ void PerformAudioPassThruRequest::Run() { // need set flag before sending to hmi StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); - if ((*message_)[str::msg_params].keyExists(str::initial_prompt) && - (0 < (*message_)[str::msg_params][str::initial_prompt].length())) { + if ((*message_)[str::msg_params].keyExists(str::initial_prompt)) { + smart_objects::SmartObject& initial_prompt = + (*message_)[strings::msg_params][strings::initial_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles( + initial_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + SendResponse( + false, + mobile_apis::Result::FILE_NOT_FOUND, + "One or more files needed for initial_prompt are not present"); + return; + } + // In case TTS Speak, subscribe on notification SendSpeakRequest(); SendPerformAudioPassThruRequest(); diff --git a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc index 68940158b9..86ab0a97c0 100644 --- a/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc +++ b/src/components/application_manager/src/commands/mobile/perform_interaction_request.cc @@ -31,6 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. */ +#include <numeric> #include <string.h> #include <string> #include "application_manager/commands/mobile/perform_interaction_request.h" @@ -536,9 +537,21 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( } } + std::vector<std::string> invalid_params; if ((*message_)[strings::msg_params].keyExists(strings::help_prompt)) { - msg_params[strings::help_prompt] = + smart_objects::SmartObject& help_prompt = (*message_)[strings::msg_params][strings::help_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(help_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_WARN(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + invalid_params.push_back("help_prompt"); + } else { + msg_params[strings::help_prompt] = help_prompt; + } } else { if (choice_list.length() != 0) { msg_params[strings::help_prompt] = @@ -573,8 +586,20 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( } if ((*message_)[strings::msg_params].keyExists(strings::timeout_prompt)) { - msg_params[strings::timeout_prompt] = + smart_objects::SmartObject& timeout_prompt = (*message_)[strings::msg_params][strings::timeout_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles( + timeout_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_WARN(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + invalid_params.push_back("timeout_prompt"); + } else { + msg_params[strings::timeout_prompt] = timeout_prompt; + } } else { if (msg_params.keyExists(strings::help_prompt)) { msg_params[strings::timeout_prompt] = msg_params[strings::help_prompt]; @@ -582,8 +607,34 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( } if ((*message_)[strings::msg_params].keyExists(strings::initial_prompt)) { - msg_params[strings::initial_prompt] = + smart_objects::SmartObject& initial_prompt = (*message_)[strings::msg_params][strings::initial_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles( + initial_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_WARN(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + invalid_params.push_back("initial_prompt"); + } else { + msg_params[strings::initial_prompt] = initial_prompt; + } + } + + if (!invalid_params.empty()) { + const std::string params_list = + std::accumulate(std::begin(invalid_params), + std::end(invalid_params), + std::string(""), + [](std::string& first, std::string& second) { + return first.empty() ? second : first + ", " + second; + }); + const std::string info = + "One or more files needed for " + params_list + " are not present"; + SendResponse(false, mobile_apis::Result::FILE_NOT_FOUND, info.c_str()); + return; } mobile_apis::InteractionMode::eType mode = diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index c799d68609..ff0d0d3622 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc @@ -50,6 +50,7 @@ #include "config_profile/profile.h" #include "interfaces/MOBILE_API.h" #include "interfaces/generated_msg_version.h" +#include "utils/file_system.h" namespace { namespace custom_str = utils::custom_string; @@ -178,7 +179,7 @@ namespace commands { RegisterAppInterfaceRequest::RegisterAppInterfaceRequest( const MessageSharedPtr& message, ApplicationManager& application_manager) : CommandRequestImpl(message, application_manager) - , result_checking_app_hmi_type_(mobile_apis::Result::INVALID_ENUM) {} + , result_code_(mobile_apis::Result::INVALID_ENUM) {} RegisterAppInterfaceRequest::~RegisterAppInterfaceRequest() {} @@ -319,7 +320,20 @@ void RegisterAppInterfaceRequest::Run() { } if (msg_params.keyExists(strings::tts_name)) { - application->set_tts_name(msg_params[strings::tts_name]); + smart_objects::SmartObject& tts_name = + (*message_)[strings::msg_params][strings::tts_name]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles( + tts_name, application, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_WARN(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + response_info_ = "One or more files needed for tts_name are not present"; + result_code_ = mobile_apis::Result::WARNINGS; + } + application->set_tts_name(tts_name); } if (msg_params.keyExists(strings::app_hmi_type)) { @@ -449,50 +463,69 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, smart_objects::SmartObject& display_caps = response_params[hmi_response::display_capabilities]; - display_caps[hmi_response::display_type] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::display_type); - - display_caps[hmi_response::text_fields] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::text_fields); - - display_caps[hmi_response::image_fields] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::image_fields); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::display_type)) { + display_caps[hmi_response::display_type] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::display_type); + } - display_caps[hmi_response::media_clock_formats] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::media_clock_formats); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::display_name)) { + display_caps[hmi_response::display_name] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::display_name); + } - display_caps[hmi_response::templates_available] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::templates_available); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::text_fields)) { + display_caps[hmi_response::text_fields] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::text_fields); + } - display_caps[hmi_response::screen_params] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::screen_params); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::image_fields)) { + display_caps[hmi_response::image_fields] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::image_fields); + } - display_caps[hmi_response::num_custom_presets_available] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::num_custom_presets_available); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::media_clock_formats)) { + display_caps[hmi_response::media_clock_formats] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::media_clock_formats); + } - display_caps[hmi_response::graphic_supported] = - (hmi_capabilities.display_capabilities() - ->getElement(hmi_response::image_capabilities) - .length() > 0); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::templates_available)) { + display_caps[hmi_response::templates_available] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::templates_available); + } - display_caps[hmi_response::templates_available] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::templates_available); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::screen_params)) { + display_caps[hmi_response::screen_params] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::screen_params); + } - display_caps[hmi_response::screen_params] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::screen_params); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::num_custom_presets_available)) { + display_caps[hmi_response::num_custom_presets_available] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::num_custom_presets_available); + } - display_caps[hmi_response::num_custom_presets_available] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::num_custom_presets_available); + if (hmi_capabilities.display_capabilities()->keyExists( + hmi_response::image_capabilities)) { + display_caps[hmi_response::graphic_supported] = + (hmi_capabilities.display_capabilities() + ->getElement(hmi_response::image_capabilities) + .length() > 0); + } } if (hmi_capabilities.audio_pass_thru_capabilities()) { @@ -693,9 +726,9 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( } } if ((mobile_apis::Result::SUCCESS == result_code) && - (mobile_apis::Result::INVALID_ENUM != result_checking_app_hmi_type_)) { + (mobile_apis::Result::INVALID_ENUM != result_code_)) { add_info += response_info_; - result_code = result_checking_app_hmi_type_; + result_code = result_code_; } // in case application exist in resumption we need to send resumeVrgrammars @@ -719,6 +752,10 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( } policy::StatusNotifier notify_upd_manager = GetPolicyHandler().AddApplication( application->policy_app_id(), hmi_types); + + response_params[strings::icon_resumed] = + file_system::FileExists(application->app_icon_path()); + SendResponse(true, result_code, add_info.c_str(), &response_params); SendOnAppRegisteredNotificationToHMI( *(application.get()), resumption, need_restore_vr); @@ -822,8 +859,9 @@ void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( msg_params[strings::tts_name] = *(application_impl.tts_name()); } + const std::string policy_app_id = application_impl.policy_app_id(); std::string priority; - GetPolicyHandler().GetPriority(application_impl.policy_app_id(), &priority); + GetPolicyHandler().GetPriority(policy_app_id, &priority); if (!priority.empty()) { msg_params[strings::priority] = MessageHelper::GetPriorityCode(priority); @@ -833,8 +871,10 @@ void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( smart_objects::SmartObject& application = msg_params[strings::application]; application[strings::app_name] = application_impl.name(); application[strings::app_id] = application_impl.app_id(); - application[hmi_response::policy_app_id] = application_impl.policy_app_id(); - application[strings::icon] = application_impl.app_icon_path(); + application[hmi_response::policy_app_id] = policy_app_id; + if (file_system::FileExists(application_impl.app_icon_path())) { + application[strings::icon] = application_impl.app_icon_path(); + } const smart_objects::SmartObject* ngn_media_screen_name = application_impl.ngn_media_screen_name(); @@ -853,18 +893,41 @@ void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( application[strings::app_type] = *app_type; } - std::vector<std::string> request_types = - GetPolicyHandler().GetAppRequestTypes(application_impl.policy_app_id()); + const policy::RequestType::State app_request_types_state = + GetPolicyHandler().GetAppRequestTypeState(policy_app_id); + if (policy::RequestType::State::AVAILABLE == app_request_types_state) { + const auto request_types = + GetPolicyHandler().GetAppRequestTypes(policy_app_id); + application[strings::request_type] = SmartObject(SmartType_Array); + smart_objects::SmartObject& request_types_array = + application[strings::request_type]; - application[strings::request_type] = SmartObject(SmartType_Array); - smart_objects::SmartObject& request_array = - application[strings::request_type]; - - uint32_t index = 0; - std::vector<std::string>::const_iterator it = request_types.begin(); - for (; request_types.end() != it; ++it) { - request_array[index] = *it; - ++index; + size_t index = 0; + for (auto it : request_types) { + request_types_array[index] = it; + ++index; + } + } else if (policy::RequestType::State::EMPTY == app_request_types_state) { + application[strings::request_type] = SmartObject(SmartType_Array); + } + + const policy::RequestSubType::State app_request_subtypes_state = + GetPolicyHandler().GetAppRequestSubTypeState(policy_app_id); + if (policy::RequestSubType::State::AVAILABLE == app_request_subtypes_state) { + const auto request_subtypes = + GetPolicyHandler().GetAppRequestSubTypes(policy_app_id); + application[strings::request_subtype] = SmartObject(SmartType_Array); + smart_objects::SmartObject& request_subtypes_array = + application[strings::request_subtype]; + + size_t index = 0; + for (auto it : request_subtypes) { + request_subtypes_array[index] = it; + ++index; + } + } else if (policy::RequestSubType::State::EMPTY == + app_request_subtypes_state) { + application[strings::request_subtype] = SmartObject(SmartType_Array); } application[strings::device_info] = SmartObject(SmartType_Map); @@ -1016,7 +1079,7 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckWithPolicyData() { "Following AppHmiTypes are not present in policy " "table:" + log; - result_checking_app_hmi_type_ = mobile_apis::Result::WARNINGS; + result_code_ = mobile_apis::Result::WARNINGS; } } // Replace AppHmiTypes in request with values allowed by policy table diff --git a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc index ee544e956a..a100bbb5fb 100644 --- a/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_app_icon_request.cc @@ -31,9 +31,10 @@ POSSIBILITY OF SUCH DAMAGE. */ -#include <algorithm> #include "application_manager/commands/mobile/set_app_icon_request.h" +#include <algorithm> + #include "application_manager/message_helper.h" #include "application_manager/application_impl.h" #include "interfaces/MOBILE_API.h" @@ -90,10 +91,6 @@ void SetAppIconRequest::Run() { return; } - if (is_icons_saving_enabled_) { - CopyToIconStorage(full_file_path); - } - smart_objects::SmartObject msg_params = smart_objects::SmartObject(smart_objects::SmartType_Map); @@ -262,6 +259,11 @@ void SetAppIconRequest::on_event(const event_engine::Event& event) { const std::string& path = (*message_)[strings::msg_params][strings::sync_file_name] [strings::value].asString(); + + if (is_icons_saving_enabled_) { + CopyToIconStorage(path); + } + app->set_app_icon_path(path); LOG4CXX_INFO(logger_, diff --git a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc index 648a531e92..ed60ca4928 100644 --- a/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_display_layout_request.cc @@ -76,9 +76,9 @@ void SetDisplayLayoutRequest::Run() { // Template layout is the same as previous layout // Reject message if colors are set if (msg_params.keyExists(strings::day_color_scheme) && - app->day_color_scheme() != NULL && - !(msg_params[strings::day_color_scheme] == - *(app->day_color_scheme()))) { + app->day_color_scheme() != NULL && + !(msg_params[strings::day_color_scheme] == + *(app->day_color_scheme()))) { // Color scheme param exists and has been previously set, do not allow // color change LOG4CXX_DEBUG(logger_, "Reject Day Color Scheme Change"); diff --git a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc index e811f5d154..621aa90447 100644 --- a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc @@ -31,6 +31,7 @@ */ #include <string.h> +#include <numeric> #include <algorithm> #include "application_manager/commands/mobile/set_global_properties_request.h" @@ -185,14 +186,54 @@ void SetGlobalPropertiesRequest::Run() { smart_objects::SmartObject params = smart_objects::SmartObject(smart_objects::SmartType_Map); + std::vector<std::string> invalid_params; if (is_help_prompt_present) { - app->set_help_prompt(msg_params.getElement(strings::help_prompt)); - params[strings::help_prompt] = (*app->help_prompt()); + smart_objects::SmartObject& help_prompt = + (*message_)[strings::msg_params][strings::help_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(help_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + invalid_params.push_back("help_prompt"); + } else { + app->set_help_prompt(help_prompt); + params[strings::help_prompt] = (*app->help_prompt()); + } } if (is_timeout_prompt_present) { - app->set_timeout_prompt(msg_params.getElement(strings::timeout_prompt)); - params[strings::timeout_prompt] = (*app->timeout_prompt()); + smart_objects::SmartObject& timeout_prompt = + (*message_)[strings::msg_params][strings::timeout_prompt]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles( + timeout_prompt, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + invalid_params.push_back("timeout_prompt"); + } else { + app->set_timeout_prompt(timeout_prompt); + params[strings::timeout_prompt] = (*app->timeout_prompt()); + } + } + + if (!invalid_params.empty()) { + std::string params_list = std::accumulate( + std::begin(invalid_params), + std::end(invalid_params), + std::string(""), + [](std::string& first, std::string& second) { + return first.empty() ? second : first + ", " + second; + }); + const std::string info = + "One or more files needed for " + params_list + " are not present"; + SendResponse(false, mobile_apis::Result::FILE_NOT_FOUND, info.c_str()); + return; } params[strings::app_id] = app->app_id(); diff --git a/src/components/application_manager/src/commands/mobile/speak_request.cc b/src/components/application_manager/src/commands/mobile/speak_request.cc index 1954cde181..6da6b482b3 100644 --- a/src/components/application_manager/src/commands/mobile/speak_request.cc +++ b/src/components/application_manager/src/commands/mobile/speak_request.cc @@ -69,6 +69,21 @@ void SpeakRequest::Run() { return; } + smart_objects::SmartObject& tts_chunks = + (*message_)[strings::msg_params][strings::tts_chunks]; + mobile_apis::Result::eType verification_result = + MessageHelper::VerifyTtsFiles(tts_chunks, app, application_manager_); + + if (mobile_apis::Result::FILE_NOT_FOUND == verification_result) { + LOG4CXX_ERROR(logger_, + "MessageHelper::VerifyTtsFiles return " + << verification_result); + SendResponse(false, + mobile_apis::Result::FILE_NOT_FOUND, + "One or more files needed for tts_chunks are not present"); + return; + } + (*message_)[strings::msg_params][strings::app_id] = app->app_id(); (*message_)[strings::msg_params][hmi_request::speak_type] = hmi_apis::Common_MethodName::SPEAK; diff --git a/src/components/application_manager/src/commands/mobile/system_request.cc b/src/components/application_manager/src/commands/mobile/system_request.cc index fe38b93732..f0331d0ced 100644 --- a/src/components/application_manager/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/src/commands/mobile/system_request.cc @@ -41,6 +41,7 @@ Copyright (c) 2013, Ford Motor Company #include "application_manager/policies/policy_handler_interface.h" #include "interfaces/MOBILE_API.h" #include "utils/file_system.h" +#include "policy/policy_table/enums.h" #include "formatters/CFormatterJsonBase.h" #include "json/json.h" #include "utils/helpers.h" @@ -454,17 +455,43 @@ void SystemRequest::Run() { const policy::PolicyHandlerInterface& policy_handler = application_manager_.GetPolicyHandler(); + + const std::string stringified_request_type = + rpc::policy_table_interface_base::EnumToJsonString( + static_cast<rpc::policy_table_interface_base::RequestType>( + request_type)); + if (!policy_handler.IsRequestTypeAllowed(application->policy_app_id(), request_type)) { + LOG4CXX_ERROR(logger_, + "RequestType " << stringified_request_type + << " is DISALLOWED by policies"); SendResponse(false, mobile_apis::Result::DISALLOWED); return; } + LOG4CXX_TRACE(logger_, + "RequestType " << stringified_request_type << " is ALLOWED"); + + const bool request_subtype_present = + (*message_)[strings::msg_params].keyExists(strings::request_subtype); + if (request_subtype_present) { + const std::string request_subtype = + (*message_)[strings::msg_params][strings::request_subtype].asString(); + if (!policy_handler.IsRequestSubTypeAllowed(application->policy_app_id(), + request_subtype)) { + LOG4CXX_ERROR(logger_, + "Request subtype: " << request_subtype + << " is DISALLOWED by policies"); + SendResponse(false, mobile_apis::Result::DISALLOWED); + return; + } + LOG4CXX_TRACE(logger_, + "Request subtype: " << request_subtype << " is ALLOWED"); + } - std::string file_name; + std::string file_name = kSYNC; if ((*message_)[strings::msg_params].keyExists(strings::file_name)) { file_name = (*message_)[strings::msg_params][strings::file_name].asString(); - } else { - file_name = kSYNC; } if (!CheckSyntax(file_name)) { @@ -481,8 +508,8 @@ void SystemRequest::Run() { return; } - bool is_system_file = std::string::npos != file_name.find(kSYNC) || - std::string::npos != file_name.find(kIVSU); + const bool is_system_file = std::string::npos != file_name.find(kSYNC) || + std::string::npos != file_name.find(kIVSU); // to avoid override existing file if (is_system_file) { @@ -587,6 +614,10 @@ void SystemRequest::Run() { msg_params[strings::request_type] = (*message_)[strings::msg_params][strings::request_type]; + if (request_subtype_present) { + msg_params[strings::request_subtype] = + (*message_)[strings::msg_params][strings::request_subtype]; + } StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_BasicCommunication); SendHMIRequest(hmi_apis::FunctionID::BasicCommunication_SystemRequest, &msg_params, diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index 278e4761db..d00fc2ae19 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -93,6 +93,8 @@ void InitCapabilities() { hmi_apis::Common_SpeechCapabilities::PRE_RECORDED)); tts_enum_capabilities.insert(std::make_pair( std::string("SILENCE"), hmi_apis::Common_SpeechCapabilities::SILENCE)); + tts_enum_capabilities.insert(std::make_pair( + std::string("FILE"), hmi_apis::Common_SpeechCapabilities::FILE)); button_enum_name.insert( std::make_pair(std::string("OK"), hmi_apis::Common_ButtonName::OK)); @@ -551,10 +553,15 @@ void HMICapabilitiesImpl::set_vr_supported_languages( void HMICapabilitiesImpl::set_display_capabilities( const smart_objects::SmartObject& display_capabilities) { - if (display_capabilities_) { - delete display_capabilities_; + if (app_mngr_.IsSOStructValid( + hmi_apis::StructIdentifiers::Common_DisplayCapabilities, + display_capabilities)) { + if (display_capabilities_) { + delete display_capabilities_; + } + display_capabilities_ = + new smart_objects::SmartObject(display_capabilities); } - display_capabilities_ = new smart_objects::SmartObject(display_capabilities); } void HMICapabilitiesImpl::set_hmi_zone_capabilities( diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index bc1ccd8f42..e1bc2b5125 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -32,11 +32,16 @@ */ #include "application_manager/hmi_state.h" +#include <ostream> +#include <boost/assign.hpp> +#include <boost/bimap.hpp> #include "application_manager/application_manager.h" #include "utils/helpers.h" namespace application_manager { +CREATE_LOGGERPTR_GLOBAL(logger_, "HmiState") + HmiState::HmiState(utils::SharedPtr<Application> app, const ApplicationManager& app_mngr, StateID state_id) @@ -45,7 +50,10 @@ HmiState::HmiState(utils::SharedPtr<Application> app, , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) - , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {} + , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) + , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { + LOG4CXX_DEBUG(logger_, *this); +} HmiState::HmiState(utils::SharedPtr<Application> app, const ApplicationManager& app_mngr) @@ -54,7 +62,10 @@ HmiState::HmiState(utils::SharedPtr<Application> app, , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) - , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {} + , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) + , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { + LOG4CXX_DEBUG(logger_, *this); +} DEPRECATED HmiState::HmiState(uint32_t app_id, const ApplicationManager& app_mngr, @@ -135,13 +146,24 @@ mobile_apis::AudioStreamingState::eType TTSHmiState::audio_streaming_state() return expected_state; } +VideoStreamingHmiState::VideoStreamingHmiState( + utils::SharedPtr<Application> app, const ApplicationManager& app_mngr) + : HmiState(app, app_mngr, STATE_ID_VIDEO_STREAMING) {} + +mobile_apis::VideoStreamingState::eType +VideoStreamingHmiState::video_streaming_state() const { + if (app_->IsVideoApplication()) { + return parent()->video_streaming_state(); + } + + return mobile_apis::VideoStreamingState::NOT_STREAMABLE; +} + NaviStreamingHmiState::NaviStreamingHmiState(utils::SharedPtr<Application> app, const ApplicationManager& app_mngr) - : HmiState(app, app_mngr, STATE_ID_NAVI_STREAMING) {} - -DEPRECATED NaviStreamingHmiState::NaviStreamingHmiState( - uint32_t app_id, const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_NAVI_STREAMING) {} + : VideoStreamingHmiState(app, app_mngr) { + set_state_id(STATE_ID_NAVI_STREAMING); +} mobile_apis::AudioStreamingState::eType NaviStreamingHmiState::audio_streaming_state() const { @@ -149,13 +171,17 @@ NaviStreamingHmiState::audio_streaming_state() const { using namespace mobile_apis; AudioStreamingState::eType expected_state = parent()->audio_streaming_state(); - if (!is_navi_app() && AudioStreamingState::AUDIBLE == expected_state) { + if (!is_navi_app() && Compare<AudioStreamingState::eType, EQ, ONE>( + expected_state, + AudioStreamingState::AUDIBLE, + AudioStreamingState::ATTENUATED)) { if (app_mngr_.is_attenuated_supported()) { expected_state = AudioStreamingState::ATTENUATED; } else { expected_state = AudioStreamingState::NOT_AUDIBLE; } } + return expected_state; } @@ -208,6 +234,7 @@ mobile_apis::HMILevel::eType DeactivateHMI::hmi_level() const { HMILevel::HMI_NONE)) { return parent()->hmi_level(); } + return HMILevel::HMI_BACKGROUND; } @@ -220,20 +247,13 @@ DEPRECATED AudioSource::AudioSource(uint32_t app_id, : HmiState(app_id, app_mngr, STATE_ID_AUDIO_SOURCE) {} mobile_apis::HMILevel::eType AudioSource::hmi_level() const { - using namespace mobile_apis; - using namespace helpers; - // TODO(AOleynik): That NONE check is necessary to avoid issue during + // Checking for NONE is necessary to avoid issue during // calculation of HMI level during setting default HMI level - // Should be investigated (used in multiple places here), since looks weird - if (Compare<HMILevel::eType, EQ, ONE>(parent()->hmi_level(), - HMILevel::HMI_BACKGROUND, - HMILevel::HMI_NONE)) { - return parent()->hmi_level(); + if (mobile_apis::HMILevel::HMI_NONE == parent()->hmi_level()) { + return mobile_apis::HMILevel::HMI_NONE; } - if (is_navi_app() || is_voice_communication_app()) { - return HMILevel::HMI_LIMITED; - } - return HMILevel::HMI_BACKGROUND; + + return mobile_apis::HMILevel::HMI_BACKGROUND; } EmbeddedNavi::EmbeddedNavi(utils::SharedPtr<Application> app, @@ -252,9 +272,46 @@ mobile_apis::HMILevel::eType EmbeddedNavi::hmi_level() const { HMILevel::HMI_NONE)) { return parent()->hmi_level(); } - if (is_media_app()) { - return HMILevel::HMI_LIMITED; - } return HMILevel::HMI_BACKGROUND; } + +namespace { +typedef boost::bimap<HmiState::StateID, std::string> StateID2StrMap; +const StateID2StrMap kStateID2StrMap = + boost::assign::list_of<StateID2StrMap::relation>( + HmiState::StateID::STATE_ID_CURRENT, "CURRENT")( + HmiState::StateID::STATE_ID_REGULAR, "REGULAR")( + HmiState::StateID::STATE_ID_POSTPONED, "POSTPONED")( + HmiState::StateID::STATE_ID_PHONE_CALL, "PHONE_CALL")( + HmiState::StateID::STATE_ID_SAFETY_MODE, "SAFETY_MODE")( + HmiState::StateID::STATE_ID_VR_SESSION, "VR_SESSION")( + HmiState::StateID::STATE_ID_TTS_SESSION, "TTS_SESSION")( + HmiState::StateID::STATE_ID_VIDEO_STREAMING, "VIDEO_STREAMING")( + HmiState::StateID::STATE_ID_NAVI_STREAMING, "NAVI_STREAMING")( + HmiState::StateID::STATE_ID_DEACTIVATE_HMI, "DEACTIVATE_HMI")( + HmiState::StateID::STATE_ID_AUDIO_SOURCE, "AUDIO_SOURCE")( + HmiState::StateID::STATE_ID_EMBEDDED_NAVI, "EMBEDDED_NAVI"); +} // anonymous namespace + +std::ostream& operator<<(std::ostream& os, const HmiState::StateID src) { + try { + os << kStateID2StrMap.left.at(src); + } catch (const std::exception&) { + // specified element have NOT been found + os << "UNRECOGNIZED(" << static_cast<int>(src) << ")"; + } + + return os; +} + +std::ostream& operator<<(std::ostream& os, const HmiState& src) { + os << "HMIState(app id:" << src.app_->app_id() << ", state:" << src.state_id() + << ", hmi_level:" << src.hmi_level() + << ", audio:" << src.audio_streaming_state() + << ", video:" << src.video_streaming_state() + << ", context:" << src.system_context() << ')'; + + return os; } + +} // namespace application_manager 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 a848cf9ad9..b674a090c0 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -2603,12 +2603,23 @@ void MessageHelper::SendOnAppPermissionsChangedNotification( if (permissions.requestTypeChanged) { smart_objects::SmartObject request_types_array( smart_objects::SmartType_Array); - ; + for (uint16_t index = 0; index < permissions.requestType.size(); ++index) { request_types_array[index] = permissions.requestType[index]; } message[strings::msg_params][strings::request_type] = request_types_array; } + if (permissions.requestSubTypeChanged) { + smart_objects::SmartObject request_subtypes_array( + smart_objects::SmartType_Array); + + for (uint16_t index = 0; index < permissions.requestSubType.size(); + ++index) { + request_subtypes_array[index] = permissions.requestSubType[index]; + } + message[strings::msg_params][strings::request_subtype] = + request_subtypes_array; + } app_mngr.ManageHMICommand( utils::MakeShared<smart_objects::SmartObject>(message)); @@ -2745,11 +2756,23 @@ mobile_apis::Result::eType MessageHelper::VerifyImageApplyPath( } const std::string& file_name = image[strings::value].asString(); + const std::string& full_file_path = GetAppFilePath(file_name, app, app_mngr); + image[strings::value] = full_file_path; + if (file_system::FileExists(full_file_path)) { + return mobile_apis::Result::SUCCESS; + } + return mobile_apis::Result::INVALID_DATA; +} + +std::string MessageHelper::GetAppFilePath(std::string file_name, + ApplicationConstSharedPtr app, + ApplicationManager& app_mngr) { std::string str = file_name; + // Verify that file name is not only space characters str.erase(remove(str.begin(), str.end(), ' '), str.end()); if (0 == str.size()) { - return mobile_apis::Result::INVALID_DATA; + return ""; } std::string full_file_path; @@ -2775,12 +2798,25 @@ mobile_apis::Result::eType MessageHelper::VerifyImageApplyPath( full_file_path += file_name; } - image[strings::value] = full_file_path; - if (!file_system::FileExists(full_file_path)) { - return mobile_apis::Result::INVALID_DATA; - } + return full_file_path; +} - return mobile_apis::Result::SUCCESS; +mobile_apis::Result::eType MessageHelper::VerifyTtsFiles( + smart_objects::SmartObject& tts_chunks, + ApplicationConstSharedPtr app, + ApplicationManager& app_mngr) { + mobile_apis::Result::eType result = mobile_apis::Result::SUCCESS; + for (auto& tts_chunk : *(tts_chunks.asArray())) { + if (tts_chunk[strings::type] == mobile_apis::SpeechCapabilities::FILE) { + const std::string full_file_path = + GetAppFilePath(tts_chunk[strings::text].asString(), app, app_mngr); + tts_chunk[strings::text] = full_file_path; + if (!file_system::FileExists(full_file_path)) { + result = mobile_apis::Result::FILE_NOT_FOUND; + } + } + } + return result; } mobile_apis::Result::eType MessageHelper::VerifyImage( @@ -3024,4 +3060,4 @@ bool MessageHelper::PrintSmartObject(const smart_objects::SmartObject& object) { return true; } -} // namespace application_manager +} // namespace application_manager
\ No newline at end of file diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 559b9c0035..67658c2809 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -54,6 +54,7 @@ #include "utils/file_system.h" #include "utils/scope_guard.h" #include "utils/make_shared.h" +#include "utils/helpers.h" #include "policy/policy_manager.h" #ifdef SDL_REMOTE_CONTROL #include "functional_module/plugin_manager.h" @@ -90,7 +91,8 @@ RequestTypeMap TypeToString = { {mobile_apis::RequestType::VEHICLE_DIAGNOSTICS, "VEHICLE_DIAGNOSTICS"}, {mobile_apis::RequestType::EMERGENCY, "EMERGENCY"}, {mobile_apis::RequestType::MEDIA, "MEDIA"}, - {mobile_apis::RequestType::FOTA, "FOTA"}}; + {mobile_apis::RequestType::FOTA, "FOTA"}, + {mobile_apis::RequestType::OEM_SPECIFIC, "OEM_SPECIFIC"}}; const std::string RequestTypeToString(mobile_apis::RequestType::eType type) { RequestTypeMap::const_iterator it = TypeToString.find(type); @@ -162,10 +164,12 @@ struct DeactivateApplication { void operator()(const ApplicationSharedPtr& app) { if (device_id_ == app->device()) { - state_ctrl_.SetRegularState(app, - mobile_apis::HMILevel::HMI_NONE, - mobile_apis::AudioStreamingState::NOT_AUDIBLE, - true); + state_ctrl_.SetRegularState( + app, + mobile_apis::HMILevel::HMI_NONE, + mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, + true); } } @@ -974,6 +978,7 @@ void PolicyHandler::OnPendingPermissionChange( app, mobile_apis::HMILevel::HMI_NONE, mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, true); policy_manager_->RemovePendingPermissionChanges(policy_app_id); return; @@ -1024,7 +1029,7 @@ void PolicyHandler::OnPendingPermissionChange( policy_manager_->RemovePendingPermissionChanges(policy_app_id); } - if (permissions.requestTypeChanged) { + if (permissions.requestTypeChanged || permissions.requestSubTypeChanged) { MessageHelper::SendOnAppPermissionsChangedNotification( app->app_id(), permissions, application_manager_); policy_manager_->RemovePendingPermissionChanges(policy_app_id); @@ -1245,12 +1250,15 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification( if (is_allowed) { // Send HMI status notification to mobile // Put application in full - AudioStreamingState::eType state = app->is_audio() - ? AudioStreamingState::AUDIBLE - : AudioStreamingState::NOT_AUDIBLE; + AudioStreamingState::eType audio_state = + app->IsAudioApplication() ? AudioStreamingState::AUDIBLE + : AudioStreamingState::NOT_AUDIBLE; + VideoStreamingState::eType video_state = + app->IsVideoApplication() ? VideoStreamingState::STREAMABLE + : VideoStreamingState::NOT_STREAMABLE; application_manager_.state_controller().SetRegularState( - app, mobile_apis::HMILevel::HMI_FULL, state, true); + app, mobile_apis::HMILevel::HMI_FULL, audio_state, video_state, true); last_activated_app_id_ = 0; } else { DeactivateApplication deactivate_notification( @@ -1879,6 +1887,18 @@ void PolicyHandler::OnAppRegisteredOnMobile(const std::string& application_id) { policy_manager_->OnAppRegisteredOnMobile(application_id); } +RequestType::State PolicyHandler::GetAppRequestTypeState( + const std::string& policy_app_id) const { + POLICY_LIB_CHECK(RequestType::State::UNAVAILABLE); + return policy_manager_->GetAppRequestTypesState(policy_app_id); +} + +RequestSubType::State PolicyHandler::GetAppRequestSubTypeState( + const std::string& policy_app_id) const { + POLICY_LIB_CHECK(RequestSubType::State::UNAVAILABLE); + return policy_manager_->GetAppRequestSubTypesState(policy_app_id); +} + bool PolicyHandler::IsRequestTypeAllowed( const std::string& policy_app_id, mobile_apis::RequestType::eType type) const { @@ -1891,17 +1911,66 @@ bool PolicyHandler::IsRequestTypeAllowed( return false; } - std::vector<std::string> request_types = - policy_manager_->GetAppRequestTypes(policy_app_id); + const RequestType::State request_type_state = + policy_manager_->GetAppRequestTypesState(policy_app_id); - // If no request types are assigned to app - any is allowed - if (request_types.empty()) { - return true; + switch (request_type_state) { + case RequestType::State::EMPTY: { + // If empty array of request types is assigned to app - any is allowed + LOG4CXX_TRACE(logger_, "Any Request Type is allowed by policies."); + return true; + } + case RequestType::State::OMITTED: { + // If RequestType parameter omitted for app - any is disallowed + LOG4CXX_TRACE(logger_, "All Request Types are disallowed by policies."); + return false; + } + case RequestType::State::AVAILABLE: { + // If any of request types is available for current application - get them + const auto request_types = + policy_manager_->GetAppRequestTypes(policy_app_id); + return helpers::in_range(request_types, stringified_type); + } + default: + return false; } +} - std::vector<std::string>::const_iterator it = - std::find(request_types.begin(), request_types.end(), stringified_type); - return request_types.end() != it; +bool PolicyHandler::IsRequestSubTypeAllowed( + const std::string& policy_app_id, + const std::string& request_subtype) const { + POLICY_LIB_CHECK(false); + using namespace mobile_apis; + + if (request_subtype.empty()) { + LOG4CXX_ERROR(logger_, "Request subtype to check is empty."); + return false; + } + + const RequestSubType::State request_subtype_state = + policy_manager_->GetAppRequestSubTypesState(policy_app_id); + switch (request_subtype_state) { + case RequestSubType::State::EMPTY: { + // If empty array of request subtypes is assigned to app - any is allowed + LOG4CXX_TRACE(logger_, "Any Request SubType is allowed by policies."); + return true; + } + case RequestSubType::State::OMITTED: { + // If RequestSubType parameter omitted for app - any is disallowed + LOG4CXX_TRACE(logger_, + "All Request SubTypes are disallowed by policies."); + return false; + } + case RequestSubType::State::AVAILABLE: { + // If any of request subtypes is available for current application + // get them all + const auto request_subtypes = + policy_manager_->GetAppRequestSubTypes(policy_app_id); + return helpers::in_range(request_subtypes, request_subtype); + } + default: + return false; + } } const std::vector<std::string> PolicyHandler::GetAppRequestTypes( @@ -1910,6 +1979,12 @@ const std::vector<std::string> PolicyHandler::GetAppRequestTypes( return policy_manager_->GetAppRequestTypes(policy_app_id); } +const std::vector<std::string> PolicyHandler::GetAppRequestSubTypes( + const std::string& policy_app_id) const { + POLICY_LIB_CHECK(std::vector<std::string>()); + return policy_manager_->GetAppRequestSubTypes(policy_app_id); +} + const VehicleInfo policy::PolicyHandler::GetVehicleInfo() const { POLICY_LIB_CHECK(VehicleInfo()); return policy_manager_->GetVehicleInfo(); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 421796c388..a55696524c 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -128,6 +128,7 @@ const char* trigger_source = "triggerSource"; const char* hmi_level = "hmiLevel"; const char* activate_app_hmi_level = "level"; const char* audio_streaming_state = "audioStreamingState"; +const char* video_streaming_state = "videoStreamingState"; const char* system_context = "systemContext"; const char* speech_capabilities = "speechCapabilities"; const char* vr_capabilities = "vrCapabilities"; @@ -151,6 +152,7 @@ const char* red = "red"; const char* green = "green"; const char* blue = "blue"; const char* display_layout = "displayLayout"; +const char* icon_resumed = "iconResumed"; // PutFile const char* sync_file_name = "syncFileName"; @@ -159,10 +161,12 @@ const char* file_type = "fileType"; const char* file_size = "fileSize"; const char* crc32_check_sum = "crc"; const char* request_type = "requestType"; +const char* request_subtype = "requestSubType"; const char* persistent_file = "persistentFile"; const char* file_data = "fileData"; const char* space_available = "spaceAvailable"; const char* image_type = "imageType"; +const char* is_template = "isTemplate"; const char* image = "image"; const char* type = "type"; const char* system_file = "systemFile"; @@ -438,6 +442,7 @@ const char* dtc = "dtc"; const char* ecu_header = "ecuHeader"; const char* image_capabilities = "imageCapabilities"; const char* display_type = "displayType"; +const char* display_name = "displayName"; const char* text_fields = "textFields"; const char* media_clock_formats = "mediaClockFormats"; const char* graphic_supported = "graphicSupported"; diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 84081a3830..9615656675 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -31,6 +31,7 @@ */ #include "application_manager/state_controller_impl.h" +#include <tuple> #include "application_manager/usage_statistics.h" #include "utils/helpers.h" #include "utils/make_shared.h" @@ -40,15 +41,18 @@ namespace application_manager { CREATE_LOGGERPTR_GLOBAL(logger_, "StateControllerImpl") -bool IsStatusChanged(HmiStatePtr old_state, HmiStatePtr new_state) { - if (old_state->hmi_level() != new_state->hmi_level() || - old_state->audio_streaming_state() != - new_state->audio_streaming_state() || - old_state->system_context() != new_state->system_context()) { - return true; - } - return false; +namespace { +bool IsStateChanged(const HmiState& old_state, const HmiState& new_state) { + return std::make_tuple(old_state.hmi_level(), + old_state.audio_streaming_state(), + old_state.video_streaming_state(), + old_state.system_context()) != + std::make_tuple(new_state.hmi_level(), + new_state.audio_streaming_state(), + new_state.video_streaming_state(), + new_state.system_context()); } +} // unnamed namespace StateControllerImpl::StateControllerImpl(ApplicationManager& app_mngr) : EventObserver(app_mngr.event_dispatcher()), app_mngr_(app_mngr) { @@ -64,20 +68,20 @@ StateControllerImpl::StateControllerImpl(ApplicationManager& app_mngr) void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, HmiStatePtr state, const bool send_activate_app) { - CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); LOG4CXX_AUTO_TRACE(logger_); - if (!app) { - LOG4CXX_ERROR(logger_, "Invalid application pointer"); - return; - } + DCHECK_OR_RETURN_VOID(app); DCHECK_OR_RETURN_VOID(state); - DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::STATE_ID_REGULAR); + DCHECK_OR_RETURN_VOID(HmiState::STATE_ID_REGULAR == state->state_id()); + + LOG4CXX_DEBUG(logger_, "Set regular state " << *state); if (state->hmi_level() == mobile_apis::HMILevel::INVALID_ENUM || state->audio_streaming_state() == mobile_apis::AudioStreamingState::INVALID_ENUM || + state->video_streaming_state() == + mobile_apis::VideoStreamingState::INVALID_ENUM || state->system_context() == mobile_apis::SystemContext::INVALID_ENUM) { - LOG4CXX_ERROR(logger_, "Get invalid state"); + LOG4CXX_ERROR(logger_, "Got invalid state"); return; } @@ -91,7 +95,8 @@ void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, app->SetPostponedState(state); return; } - hmi_apis::Common_HMILevel::eType hmi_level = + LOG4CXX_DEBUG(logger_, "Resolved state: " << *resolved_state); + const hmi_apis::Common_HMILevel::eType hmi_level = static_cast<hmi_apis::Common_HMILevel::eType>( resolved_state->hmi_level()); @@ -100,7 +105,7 @@ void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, if (-1 != corr_id) { subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_ActivateApp, corr_id); - waiting_for_activate[app->app_id()] = resolved_state; + waiting_for_activate_[app->app_id()] = resolved_state; return; } LOG4CXX_ERROR(logger_, "Unable to send BC.ActivateApp"); @@ -113,13 +118,10 @@ void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state, const bool send_activate_app) { - CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); LOG4CXX_AUTO_TRACE(logger_); - if (!app) { - LOG4CXX_ERROR(logger_, "Invalid application pointer"); - return; - } + DCHECK_OR_RETURN_VOID(app); HmiStatePtr prev_regular = app->RegularHmiState(); DCHECK_OR_RETURN_VOID(prev_regular); HmiStatePtr hmi_state = @@ -127,6 +129,7 @@ void StateControllerImpl::SetRegularState( DCHECK_OR_RETURN_VOID(hmi_state); hmi_state->set_hmi_level(hmi_level); hmi_state->set_audio_streaming_state(audio_state); + hmi_state->set_video_streaming_state(video_state); hmi_state->set_system_context(prev_regular->system_context()); SetRegularState(app, hmi_state, send_activate_app); } @@ -136,19 +139,15 @@ void StateControllerImpl::SetRegularState( const mobile_apis::HMILevel::eType hmi_level, const bool send_activate_app) { using namespace mobile_apis; - using namespace helpers; - CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); LOG4CXX_AUTO_TRACE(logger_); - if (!app) { - LOG4CXX_ERROR(logger_, "Invalid application pointer"); - return; - } + DCHECK_OR_RETURN_VOID(app); const HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(hmi_state); hmi_state->set_hmi_level(hmi_level); hmi_state->set_audio_streaming_state(CalcAudioState(app, hmi_level)); + hmi_state->set_video_streaming_state(CalcVideoState(app, hmi_level)); hmi_state->set_system_context(SystemContext::SYSCTXT_MAIN); SetRegularState(app, hmi_state, send_activate_app); } @@ -157,37 +156,32 @@ void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state, const mobile_apis::SystemContext::eType system_context, const bool send_activate_app) { - CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); LOG4CXX_AUTO_TRACE(logger_); - if (!app) { - LOG4CXX_ERROR(logger_, "Invalid application pointer"); - return; - } + DCHECK_OR_RETURN_VOID(app); HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(hmi_state); hmi_state->set_hmi_level(hmi_level); hmi_state->set_audio_streaming_state(audio_state); + hmi_state->set_video_streaming_state(video_state); hmi_state->set_system_context(system_context); SetRegularState(app, hmi_state, send_activate_app); } void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level) { - CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); LOG4CXX_AUTO_TRACE(logger_); - if (!app) { - LOG4CXX_ERROR(logger_, "Invalid application pointer"); - return; - } + DCHECK_OR_RETURN_VOID(app); HmiStatePtr prev_state = app->RegularHmiState(); HmiStatePtr hmi_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(hmi_state); hmi_state->set_hmi_level(hmi_level); hmi_state->set_audio_streaming_state(CalcAudioState(app, hmi_level)); + hmi_state->set_video_streaming_state(CalcVideoState(app, hmi_level)); hmi_state->set_system_context(prev_state ? prev_state->system_context() : mobile_apis::SystemContext::SYSCTXT_MAIN); @@ -197,12 +191,8 @@ void StateControllerImpl::SetRegularState( void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, const mobile_apis::SystemContext::eType system_context) { - CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); LOG4CXX_AUTO_TRACE(logger_); - if (!app) { - LOG4CXX_ERROR(logger_, "Invalid application pointer"); - return; - } + DCHECK_OR_RETURN_VOID(app); HmiStatePtr prev_regular = app->RegularHmiState(); DCHECK_OR_RETURN_VOID(prev_regular); HmiStatePtr hmi_state = @@ -211,19 +201,18 @@ void StateControllerImpl::SetRegularState( hmi_state->set_hmi_level(prev_regular->hmi_level()); hmi_state->set_audio_streaming_state( CalcAudioState(app, prev_regular->hmi_level())); + hmi_state->set_video_streaming_state( + CalcVideoState(app, prev_regular->hmi_level())); hmi_state->set_system_context(system_context); SetRegularState(app, hmi_state, false); } void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, - const mobile_apis::AudioStreamingState::eType audio_state) { - CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state) { LOG4CXX_AUTO_TRACE(logger_); - if (!app) { - LOG4CXX_ERROR(logger_, "Invalid application pointer"); - return; - } + DCHECK_OR_RETURN_VOID(app); HmiStatePtr prev_state = app->RegularHmiState(); DCHECK_OR_RETURN_VOID(prev_state); HmiStatePtr hmi_state = @@ -231,18 +220,15 @@ void StateControllerImpl::SetRegularState( DCHECK_OR_RETURN_VOID(hmi_state); hmi_state->set_hmi_level(prev_state->hmi_level()); hmi_state->set_audio_streaming_state(audio_state); + hmi_state->set_video_streaming_state(video_state); hmi_state->set_system_context(prev_state->system_context()); SetRegularState(app, hmi_state, false); } void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, HmiStatePtr state) { - CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); LOG4CXX_AUTO_TRACE(logger_); - if (!app) { - LOG4CXX_ERROR(logger_, "Invalid application pointer"); - return; - } + DCHECK_OR_RETURN_VOID(app); DCHECK_OR_RETURN_VOID(state); if (mobile_apis::HMILevel::HMI_FULL == state->hmi_level()) { SetRegularState(app, state, true); @@ -251,84 +237,178 @@ void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, } } -void StateControllerImpl::HmiLevelConflictResolver::operator()( - ApplicationSharedPtr to_resolve) { - using namespace mobile_apis; +namespace { + +/** + * @brief IsStreamableHMILevel checks whether the HMI level + * supports audio/video streaming. + * @param val HMI level + * @return true if streamable, false otherwise + */ +bool IsStreamableHMILevel(mobile_apis::HMILevel::eType val) { using namespace helpers; + return Compare<mobile_apis::HMILevel::eType, EQ, ONE>( + val, mobile_apis::HMILevel::HMI_FULL, mobile_apis::HMILevel::HMI_LIMITED); +} + +/** + * @brief IsSameAudioAppType checks whether the both applications: + * 1) belongs to exact HMI type that may stream audio without + * 'isMediaApplication' parameter set to true ('NAVIGATION', 'COMMUNICATION') + * 2) belongs to other HMI types with parameter 'isMediaApplication' + * is set to true. + * 3) are not media. + * @param app1 1st application + * @param app2 2nd application + * @return true if audio applications have same application HMI type + */ +bool IsSameAudioAppType(const Application& app1, const Application& app2) { + const auto is_only_media_app_type = [](const Application& app) { + return app.is_media_application() && !app.is_navi() && + !app.is_voice_communication_supported(); + }; + + const bool both_navi = app1.is_navi() && app2.is_navi(); + const bool both_vc = app1.is_voice_communication_supported() && + app2.is_voice_communication_supported(); + const bool both_media = + is_only_media_app_type(app1) && is_only_media_app_type(app2); + const bool both_other = + !app1.IsAudioApplication() && !app2.IsAudioApplication(); + const bool same_app_audio_type = + both_navi || both_vc || both_media || both_other; + + return same_app_audio_type; +} +} // unnamed namespace + +void StateControllerImpl::HmiLevelConflictResolver::operator()( + ApplicationSharedPtr app_to_resolve) { + DCHECK_OR_RETURN_VOID(app_to_resolve); DCHECK_OR_RETURN_VOID(state_ctrl_); - if (to_resolve == applied_) + DCHECK_OR_RETURN_VOID(applied_); + DCHECK_OR_RETURN_VOID(state_); + + if (applied_ == app_to_resolve) { + // Same app. Nothing to resolve return; - HmiStatePtr cur_state = to_resolve->RegularHmiState(); - - const bool applied_grabs_audio = - Compare<HMILevel::eType, EQ, ONE>( - state_->hmi_level(), HMILevel::HMI_FULL, HMILevel::HMI_LIMITED) && - applied_->IsAudioApplication(); - const bool applied_grabs_full = state_->hmi_level() == HMILevel::HMI_FULL; - const bool to_resolve_handles_full = - cur_state->hmi_level() == HMILevel::HMI_FULL; - const bool to_resolve_handles_audio = - Compare<HMILevel::eType, EQ, ONE>( - cur_state->hmi_level(), HMILevel::HMI_FULL, HMILevel::HMI_LIMITED) && - to_resolve->IsAudioApplication(); - const bool same_app_type = state_ctrl_->IsSameAppType(applied_, to_resolve); - - // If applied Hmi state is FULL: - // all not audio applications will get BACKGROUND - // all applications with same HMI type will get BACKGROUND - // all audio applications with other HMI type(navi, vc, media) in FULL will - // get LIMMITED HMI level - - // If applied Hmi state is LIMITED: - // all applications with other HMI types will save HMI states - // all not audio applications will save HMI states - // all applications with same HMI type will get BACKGROUND - - // If applied Hmi state is BACKGROUND: - // all applications will save HMI states - - HMILevel::eType result_hmi_level = cur_state->hmi_level(); - if (applied_grabs_full && to_resolve_handles_audio && !same_app_type) - result_hmi_level = HMILevel::HMI_LIMITED; - - if ((applied_grabs_full && to_resolve_handles_full && - !to_resolve->IsAudioApplication()) || - (applied_grabs_audio && to_resolve_handles_audio && same_app_type)) - result_hmi_level = HMILevel::HMI_BACKGROUND; - - if (cur_state->hmi_level() != result_hmi_level) { + } + + const HmiStatePtr state_to_resolve = app_to_resolve->RegularHmiState(); + DCHECK_OR_RETURN_VOID(state_to_resolve); + + // If applied HMI state is FULL: + // - all NOT audio/video applications becomes BACKGROUND + // - all audio/video applications with other app type + // (navi, vc, media, projection) in FULL becomes LIMMITED + // - all audio/video applications with same app type becomes BACKGROUND + // + // If applied HMI state is LIMITED: + // - all NOT audio/video applications saves their's HMI states + // - all applications with other app types saves their's HMI states + // - all audio/video applications with same app type becomes BACKGROUND + + if (!IsStreamableHMILevel(state_->hmi_level())) { + LOG4CXX_DEBUG(logger_, + "Applied for app " << applied_->app_id() << " HMI level " + << state_->hmi_level() + << " is NOT streamable. Exit."); + return; + } + + if (!IsStreamableHMILevel(state_to_resolve->hmi_level())) { + LOG4CXX_DEBUG(logger_, + "To resolve app " << app_to_resolve->app_id() << " HMI level " + << state_to_resolve->hmi_level() + << " is NOT streamable. Exit."); + return; + } + + // Applied app constants + const auto applied_hmi_level = state_->hmi_level(); + + const bool applied_grabs_video = + IsStreamableHMILevel(applied_hmi_level) && applied_->IsVideoApplication(); + + // App to resolve constants + const auto to_resolve_hmi_level = state_to_resolve->hmi_level(); + + const bool to_resolve_grabs_audio = + IsStreamableHMILevel(to_resolve_hmi_level) && + app_to_resolve->IsAudioApplication(); + + const bool to_resolve_grabs_video = + IsStreamableHMILevel(to_resolve_hmi_level) && + app_to_resolve->IsVideoApplication(); + + // Compatibility constants + const bool same_app_audio_type = + IsSameAudioAppType(*applied_, *app_to_resolve); + + // Result variables + mobile_apis::VideoStreamingState::eType result_video_state = + mobile_apis::VideoStreamingState::NOT_STREAMABLE; + mobile_apis::AudioStreamingState::eType result_audio_state = + mobile_apis::AudioStreamingState::NOT_AUDIBLE; + + if (to_resolve_grabs_audio && !same_app_audio_type) { + result_audio_state = mobile_apis::AudioStreamingState::AUDIBLE; + } + + if (to_resolve_grabs_video && !applied_grabs_video) { + result_video_state = mobile_apis::VideoStreamingState::STREAMABLE; + } + + mobile_apis::HMILevel::eType result_hmi_level = state_to_resolve->hmi_level(); + + using namespace helpers; + if (mobile_apis::VideoStreamingState::STREAMABLE == result_video_state || + Compare<mobile_apis::AudioStreamingState::eType, EQ, ONE>( + result_audio_state, + mobile_apis::AudioStreamingState::AUDIBLE, + mobile_apis::AudioStreamingState::ATTENUATED)) { + result_hmi_level = mobile_apis::HMILevel::HMI_LIMITED; + } else { + result_hmi_level = mobile_apis::HMILevel::HMI_BACKGROUND; + } + + if (std::make_tuple(to_resolve_hmi_level, + state_to_resolve->audio_streaming_state(), + state_to_resolve->video_streaming_state()) != + std::make_tuple( + result_hmi_level, result_audio_state, result_video_state)) { LOG4CXX_DEBUG(logger_, - "Application " << to_resolve->app_id() - << " will change HMI level to " - << result_hmi_level); - state_ctrl_->SetupRegularHmiState(to_resolve, + "Application " + << app_to_resolve->app_id() << " will change state to: " + << "HMI level " << to_resolve_hmi_level << " --> " + << result_hmi_level << ", audio " + << state_to_resolve->audio_streaming_state() << " --> " + << result_audio_state << ", video " + << state_to_resolve->video_streaming_state() << " --> " + << result_video_state); + state_ctrl_->SetupRegularHmiState(app_to_resolve, result_hmi_level, - result_hmi_level == HMILevel::HMI_LIMITED - ? AudioStreamingState::AUDIBLE - : AudioStreamingState::NOT_AUDIBLE); + result_audio_state, + result_video_state); } else { LOG4CXX_DEBUG(logger_, - "Application " << to_resolve->app_id() - << " will not change HMI level"); + "Application " << app_to_resolve->app_id() + << " will NOT change HMI level"); } } HmiStatePtr StateControllerImpl::ResolveHmiState(ApplicationSharedPtr app, HmiStatePtr state) const { using namespace mobile_apis; - using namespace helpers; LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, - "State to resolve: hmi_level " - << state->hmi_level() << ", audio_state " - << state->audio_streaming_state() << ", system_context " - << state->system_context()); + LOG4CXX_DEBUG(logger_, "State to resolve: " << *state); HmiStatePtr available_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN(available_state, HmiStatePtr()); available_state->set_hmi_level(state->hmi_level()); available_state->set_audio_streaming_state(state->audio_streaming_state()); + available_state->set_video_streaming_state(state->video_streaming_state()); available_state->set_system_context(state->system_context()); if (app->is_resuming()) { @@ -337,6 +417,8 @@ HmiStatePtr StateControllerImpl::ResolveHmiState(ApplicationSharedPtr app, available_state->set_hmi_level(available_level); available_state->set_audio_streaming_state( CalcAudioState(app, available_level)); + available_state->set_video_streaming_state( + CalcVideoState(app, available_level)); } return IsStateAvailable(app, available_state) ? available_state : HmiStatePtr(); @@ -345,11 +427,8 @@ HmiStatePtr StateControllerImpl::ResolveHmiState(ApplicationSharedPtr app, bool StateControllerImpl::IsResumptionAllowed(ApplicationSharedPtr app, HmiStatePtr state) const { LOG4CXX_AUTO_TRACE(logger_); - using namespace helpers; using namespace mobile_apis; - if (!app->is_resuming() || - !Compare<HMILevel::eType, EQ, ONE>( - state->hmi_level(), HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { + if (!app->is_resuming() || !IsStreamableHMILevel(state->hmi_level())) { LOG4CXX_DEBUG(logger_, "Application is not in resuming mode."); return true; } @@ -375,20 +454,17 @@ bool StateControllerImpl::IsResumptionAllowed(ApplicationSharedPtr app, mobile_apis::HMILevel::eType StateControllerImpl::GetAvailableHmiLevel( ApplicationSharedPtr app, mobile_apis::HMILevel::eType hmi_level) const { - using namespace mobile_apis; - using namespace helpers; LOG4CXX_AUTO_TRACE(logger_); mobile_apis::HMILevel::eType result = hmi_level; - if (!Compare<HMILevel::eType, EQ, ONE>( - hmi_level, HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { + if (!IsStreamableHMILevel(hmi_level)) { return result; } const bool is_audio_app = app->IsAudioApplication(); const bool does_audio_app_with_same_type_exist = app_mngr_.IsAppTypeExistsInFullOrLimited(app); - if (HMILevel::HMI_LIMITED == hmi_level) { + if (mobile_apis::HMILevel::HMI_LIMITED == hmi_level) { if (!is_audio_app || does_audio_app_with_same_type_exist) { result = app_mngr_.GetDefaultHmiLevel(app); } @@ -424,13 +500,8 @@ mobile_apis::HMILevel::eType StateControllerImpl::GetAvailableHmiLevel( bool StateControllerImpl::IsStateAvailable(ApplicationSharedPtr app, HmiStatePtr state) const { using namespace mobile_apis; - using namespace helpers; LOG4CXX_AUTO_TRACE(logger_); - LOG4CXX_DEBUG(logger_, - "Checking state: hmi_level " - << state->hmi_level() << ", audio_state " - << state->audio_streaming_state() << ", system_context " - << state->system_context()); + LOG4CXX_DEBUG(logger_, "Checking state: " << *state); if (app->is_resuming()) { return IsStateAvailableForResumption(app, state); @@ -454,11 +525,8 @@ bool StateControllerImpl::IsStateAvailableForResumption( ApplicationSharedPtr app, HmiStatePtr state) const { LOG4CXX_AUTO_TRACE(logger_); using namespace mobile_apis; - using namespace helpers; - if (!app->is_resuming() || - !Compare<HMILevel::eType, EQ, ONE>( - state->hmi_level(), HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { + if (!app->is_resuming() || !IsStreamableHMILevel(state->hmi_level())) { LOG4CXX_DEBUG(logger_, "Application is not in resuming mode." << " Requested state is available"); @@ -492,20 +560,17 @@ bool StateControllerImpl::IsStateAvailableForResumption( void StateControllerImpl::SetupRegularHmiState(ApplicationSharedPtr app, HmiStatePtr state) { - namespace HMILevel = mobile_apis::HMILevel; - namespace AudioStreamingState = mobile_apis::AudioStreamingState; + using namespace mobile_apis; LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(state); - LOG4CXX_DEBUG(logger_, - "hmi_level " << state->hmi_level() << ", audio_state " - << state->audio_streaming_state() - << ", system_context " << state->system_context()); + LOG4CXX_DEBUG(logger_, "Setup regular state: " << *state); HmiStatePtr curr_state = app->CurrentHmiState(); HmiStatePtr old_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(old_state); old_state->set_hmi_level(curr_state->hmi_level()); old_state->set_audio_streaming_state(curr_state->audio_streaming_state()); + old_state->set_video_streaming_state(curr_state->video_streaming_state()); old_state->set_system_context(curr_state->system_context()); app->SetRegularState(state); @@ -524,10 +589,8 @@ void StateControllerImpl::SetupRegularHmiState(ApplicationSharedPtr app, void StateControllerImpl::SetupRegularHmiState( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, - const mobile_apis::AudioStreamingState::eType audio_state) { - namespace HMILevel = mobile_apis::HMILevel; - namespace AudioStreamingState = mobile_apis::AudioStreamingState; - using helpers::Compare; + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); HmiStatePtr prev_state = app->RegularHmiState(); @@ -537,6 +600,7 @@ void StateControllerImpl::SetupRegularHmiState( DCHECK_OR_RETURN_VOID(new_state); new_state->set_hmi_level(hmi_level); new_state->set_audio_streaming_state(audio_state); + new_state->set_video_streaming_state(video_state); new_state->set_system_context(prev_state->system_context()); SetupRegularHmiState(app, new_state); } @@ -547,28 +611,12 @@ void StateControllerImpl::ApplyRegularState(ApplicationSharedPtr app, DCHECK_OR_RETURN_VOID(app); DCHECK_OR_RETURN_VOID(state); DCHECK_OR_RETURN_VOID(state->state_id() == HmiState::STATE_ID_REGULAR); + LOG4CXX_DEBUG(logger_, + "Applying to app " << app->app_id() << " state " << *state); SetupRegularHmiState(app, state); - ForEachApplication<HmiLevelConflictResolver>( - HmiLevelConflictResolver(app, state, this)); -} - -bool StateControllerImpl::IsSameAppType(ApplicationConstSharedPtr app1, - ApplicationConstSharedPtr app2) { - const bool both_media = - app1->is_media_application() && app2->is_media_application(); - - const bool both_navi = app1->is_navi() && app2->is_navi(); - - const bool both_vc = app1->is_voice_communication_supported() && - app2->is_voice_communication_supported(); - - const bool both_simple = - !app1->IsAudioApplication() && !app2->IsAudioApplication(); - - const bool both_projection = - app1->mobile_projection_enabled() && app2->mobile_projection_enabled(); - - return both_simple || both_media || both_navi || both_vc || both_projection; + LOG4CXX_DEBUG(logger_, + "Resolving HMI level conflicts for app " << app->app_id()); + ForEachApplication(HmiLevelConflictResolver(app, state, this)); } void StateControllerImpl::on_event(const event_engine::Event& event) { @@ -615,7 +663,7 @@ void StateControllerImpl::on_event(const event_engine::Event& event) { const uint32_t id = message[strings::msg_params][hmi_notification::event_name].asUInt(); // TODO(AOleynik): Add verification/conversion check here - Common_EventTypes::eType state_id = + const Common_EventTypes::eType state_id = static_cast<Common_EventTypes::eType>(id); if (is_active) { if (Common_EventTypes::AUDIO_SOURCE == state_id) { @@ -660,6 +708,9 @@ void StateControllerImpl::on_event(const event_engine::Event& event) { break; } } + + LOG4CXX_WARN(logger_, + "Couldn't recognize state id (val='" << state_id << "')"); break; } default: @@ -674,17 +725,9 @@ void StateControllerImpl::OnStateChanged(ApplicationSharedPtr app, DCHECK_OR_RETURN_VOID(app); DCHECK_OR_RETURN_VOID(old_state); DCHECK_OR_RETURN_VOID(new_state); - LOG4CXX_DEBUG(logger_, - "old: hmi_level " << old_state->hmi_level() << ", audio_state " - << old_state->audio_streaming_state() - << ", system_context " - << old_state->system_context()); - LOG4CXX_DEBUG(logger_, - "new: hmi_level " << new_state->hmi_level() << ", audio_state " - << new_state->audio_streaming_state() - << ", system_context " - << new_state->system_context()); - if (IsStatusChanged(old_state, new_state)) { + LOG4CXX_DEBUG(logger_, "Old state: " << *old_state); + LOG4CXX_DEBUG(logger_, "New state: " << *new_state); + if (IsStateChanged(*old_state, *new_state)) { app_mngr_.SendHMIStatusNotification(app); if (new_state->hmi_level() == mobile_apis::HMILevel::HMI_NONE) { app->ResetDataInNone(); @@ -693,15 +736,13 @@ void StateControllerImpl::OnStateChanged(ApplicationSharedPtr app, app->app_id(), old_state->hmi_level(), new_state->hmi_level()); app->usage_report().RecordHmiStateChanged(new_state->hmi_level()); } else { - LOG4CXX_ERROR(logger_, "Status not changed"); + LOG4CXX_ERROR(logger_, "State has NOT been changed."); } } -bool StateControllerImpl::IsTempStateActive(HmiState::StateID ID) const { +bool StateControllerImpl::IsTempStateActive(HmiState::StateID id) const { sync_primitives::AutoLock autolock(active_states_lock_); - StateIDList::const_iterator itr = - std::find(active_states_.begin(), active_states_.end(), ID); - return active_states_.end() != itr; + return helpers::in_range(active_states_, id); } void StateControllerImpl::OnApplicationRegistered( @@ -713,23 +754,25 @@ void StateControllerImpl::OnApplicationRegistered( LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - active_states_lock_.Acquire(); - StateIDList::iterator it = active_states_.begin(); - for (; it != active_states_.end(); ++it) { - HmiStatePtr new_state = CreateHmiState(app, *it); - DCHECK_OR_RETURN_VOID(new_state); - DCHECK_OR_RETURN_VOID(new_state->state_id() != HmiState::STATE_ID_REGULAR); - HmiStatePtr old_hmi_state = app->CurrentHmiState(); - new_state->set_parent(old_hmi_state); - app->AddHMIState(new_state); + { + sync_primitives::AutoLock lck(active_states_lock_); + for (const auto state_id : active_states_) { + HmiStatePtr new_state = CreateHmiState(app, state_id); + DCHECK_OR_RETURN_VOID(new_state); + DCHECK_OR_RETURN_VOID(new_state->state_id() != + HmiState::STATE_ID_REGULAR); + HmiStatePtr old_hmi_state = app->CurrentHmiState(); + new_state->set_parent(old_hmi_state); + app->AddHMIState(new_state); + } } - active_states_lock_.Release(); HmiStatePtr default_state = CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR); DCHECK_OR_RETURN_VOID(default_state); default_state->set_hmi_level(default_level); default_state->set_audio_streaming_state(CalcAudioState(app, default_level)); + default_state->set_video_streaming_state(CalcVideoState(app, default_level)); default_state->set_system_context(SystemContext::SYSCTXT_MAIN); HmiStatePtr initial_state = app->RegularHmiState(); @@ -778,16 +821,18 @@ void StateControllerImpl::ApplyPostponedStateForApp(ApplicationSharedPtr app) { } } -void StateControllerImpl::TempStateStarted(HmiState::StateID ID) { +void StateControllerImpl::TempStateStarted(HmiState::StateID id) { LOG4CXX_AUTO_TRACE(logger_); - sync_primitives::AutoLock autolock(active_states_lock_); - StateIDList::iterator it = - std::find(active_states_.begin(), active_states_.end(), ID); - if (it == active_states_.end()) { - active_states_.push_back(ID); - } else { - LOG4CXX_ERROR(logger_, "StateID " << ID << " is already active"); + + { + sync_primitives::AutoLock autolock(active_states_lock_); + if (!helpers::in_range(active_states_, id)) { + active_states_.push_back(id); + return; + } } + + LOG4CXX_ERROR(logger_, "StateID '" << id << "' is already active"); } void StateControllerImpl::TempStateStopped(HmiState::StateID ID) { @@ -805,16 +850,34 @@ void StateControllerImpl::DeactivateApp(ApplicationSharedPtr app) { LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); - HmiStatePtr regular = app->RegularHmiState(); + const HmiStatePtr regular = app->RegularHmiState(); DCHECK_OR_RETURN_VOID(regular); HmiStatePtr new_regular = utils::MakeShared<HmiState>(*regular); - if (app->IsAudioApplication()) { + LOG4CXX_DEBUG(logger_, "Current HMI level: '" << app->hmi_level() << "'"); + const bool is_audio_app = app->IsAudioApplication(); + const bool is_video_app = app->IsVideoApplication(); + + if (is_audio_app || is_video_app) { + // audio or video app move to HMI level limited new_regular->set_hmi_level(HMILevel::HMI_LIMITED); - new_regular->set_audio_streaming_state(AudioStreamingState::AUDIBLE); + + if (is_audio_app) { + new_regular->set_audio_streaming_state(AudioStreamingState::AUDIBLE); + } else { + new_regular->set_audio_streaming_state(AudioStreamingState::NOT_AUDIBLE); + } + + if (is_video_app) { + new_regular->set_video_streaming_state(VideoStreamingState::STREAMABLE); + } else { + new_regular->set_video_streaming_state( + VideoStreamingState::NOT_STREAMABLE); + } } else { new_regular->set_hmi_level(HMILevel::HMI_BACKGROUND); new_regular->set_audio_streaming_state(AudioStreamingState::NOT_AUDIBLE); + new_regular->set_video_streaming_state(VideoStreamingState::NOT_STREAMABLE); } SetRegularState(app, new_regular, false); @@ -831,7 +894,7 @@ void StateControllerImpl::OnActivateAppResponse( ApplicationSharedPtr application = app_mngr_.application_by_hmi_app(hmi_app_id); if (application && hmi_apis::Common_Result::SUCCESS == code) { - HmiStatePtr pending_state = waiting_for_activate[application->app_id()]; + HmiStatePtr pending_state = waiting_for_activate_[application->app_id()]; DCHECK_OR_RETURN_VOID(pending_state); ApplyRegularState(application, pending_state); } @@ -854,9 +917,7 @@ void StateControllerImpl::OnAppActivated( void StateControllerImpl::OnAppDeactivated( const smart_objects::SmartObject& message) { - using namespace hmi_apis; using namespace mobile_apis; - using namespace helpers; LOG4CXX_AUTO_TRACE(logger_); uint32_t app_id = message[strings::msg_params][strings::app_id].asUInt(); @@ -875,12 +936,22 @@ void StateControllerImpl::OnAppDeactivated( DeactivateApp(app); } -void StateControllerImpl::OnNaviStreamingStarted() { - ApplyTempState<HmiState::STATE_ID_NAVI_STREAMING>(); +void StateControllerImpl::OnVideoStreamingStarted( + ApplicationConstSharedPtr app) { + if (app->is_navi()) { + ApplyTempState<HmiState::STATE_ID_NAVI_STREAMING>(); + } else { + ApplyTempState<HmiState::STATE_ID_VIDEO_STREAMING>(); + } } -void StateControllerImpl::OnNaviStreamingStopped() { - CancelTempState<HmiState::STATE_ID_NAVI_STREAMING>(); +void StateControllerImpl::OnVideoStreamingStopped( + ApplicationConstSharedPtr app) { + if (app->is_navi()) { + CancelTempState<HmiState::STATE_ID_NAVI_STREAMING>(); + } else { + CancelTempState<HmiState::STATE_ID_VIDEO_STREAMING>(); + } } bool StateControllerImpl::IsStateActive(HmiState::StateID state_id) const { @@ -917,6 +988,10 @@ HmiStatePtr StateControllerImpl::CreateHmiState( new_state = MakeShared<TTSHmiState>(app, app_mngr_); break; } + case HmiState::STATE_ID_VIDEO_STREAMING: { + new_state = MakeShared<VideoStreamingHmiState>(app, app_mngr_); + break; + } case HmiState::STATE_ID_NAVI_STREAMING: { new_state = MakeShared<NaviStreamingHmiState>(app, app_mngr_); break; @@ -952,20 +1027,31 @@ HmiStatePtr StateControllerImpl::CreateHmiState( mobile_apis::AudioStreamingState::eType StateControllerImpl::CalcAudioState( ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level) const { - namespace HMILevel = mobile_apis::HMILevel; - namespace AudioStreamingState = mobile_apis::AudioStreamingState; - using helpers::Compare; - using helpers::EQ; - using helpers::ONE; - - AudioStreamingState::eType audio_state = AudioStreamingState::NOT_AUDIBLE; - if (Compare<HMILevel::eType, EQ, ONE>( - hmi_level, HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { - if (app->IsAudioApplication()) { - audio_state = AudioStreamingState::AUDIBLE; - } + auto state = mobile_apis::AudioStreamingState::NOT_AUDIBLE; + if (IsStreamableHMILevel(hmi_level) && app->IsAudioApplication()) { + state = mobile_apis::AudioStreamingState::AUDIBLE; } - return audio_state; + + LOG4CXX_DEBUG(logger_, + "Calculated audio state of app " + << app->app_id() << " for " << hmi_level << " HMI level is " + << state); + return state; +} + +mobile_apis::VideoStreamingState::eType StateControllerImpl::CalcVideoState( + ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType hmi_level) const { + auto state = mobile_apis::VideoStreamingState::NOT_STREAMABLE; + if (IsStreamableHMILevel(hmi_level) && app->IsVideoApplication()) { + state = mobile_apis::VideoStreamingState::STREAMABLE; + } + + LOG4CXX_DEBUG(logger_, + "Calculated video state of app " + << app->app_id() << " for " << hmi_level << " HMI level is " + << state); + return state; } } // namespace application_manager diff --git a/src/components/application_manager/test/application_impl_test.cc b/src/components/application_manager/test/application_impl_test.cc index 6b7f78b8f7..be2986e719 100644 --- a/src/components/application_manager/test/application_impl_test.cc +++ b/src/components/application_manager/test/application_impl_test.cc @@ -179,7 +179,7 @@ TEST_F(ApplicationImplTest, AddStateAddRegularState_GetCurrentState) { HmiState::STATE_ID_REGULAR, &ApplicationImpl::SetRegularState); TestAddHmiState(HMILevel::HMI_LIMITED, - HmiState::STATE_ID_NAVI_STREAMING, + HmiState::STATE_ID_VIDEO_STREAMING, &ApplicationImpl::AddHMIState); CheckCurrentHMIState(); @@ -191,7 +191,7 @@ TEST_F(ApplicationImplTest, AddStateAddRegularState_GetRegularState) { HmiState::STATE_ID_REGULAR, &ApplicationImpl::SetRegularState); TestAddHmiState(HMILevel::HMI_LIMITED, - HmiState::STATE_ID_NAVI_STREAMING, + HmiState::STATE_ID_VIDEO_STREAMING, &ApplicationImpl::AddHMIState); HmiStatePtr current_state = app_impl->RegularHmiState(); @@ -206,7 +206,7 @@ TEST_F(ApplicationImplTest, AddStates_RemoveLastState) { HmiState::STATE_ID_PHONE_CALL, &ApplicationImpl::AddHMIState); HmiStatePtr state2 = TestAddHmiState(HMILevel::HMI_NONE, - HmiState::STATE_ID_NAVI_STREAMING, + HmiState::STATE_ID_VIDEO_STREAMING, &ApplicationImpl::AddHMIState); HmiStatePtr state3 = TestAddHmiState(HMILevel::HMI_LIMITED, HmiState::STATE_ID_TTS_SESSION, @@ -219,7 +219,7 @@ TEST_F(ApplicationImplTest, AddStates_RemoveLastState) { HmiStatePtr current_state = app_impl->CurrentHmiState(); EXPECT_EQ(state2, current_state); EXPECT_EQ(HMILevel::HMI_NONE, current_state->hmi_level()); - EXPECT_EQ(HmiState::STATE_ID_NAVI_STREAMING, current_state->state_id()); + EXPECT_EQ(HmiState::STATE_ID_VIDEO_STREAMING, current_state->state_id()); } TEST_F(ApplicationImplTest, AddStates_RemoveNotLastNotFirstState) { @@ -227,7 +227,7 @@ TEST_F(ApplicationImplTest, AddStates_RemoveNotLastNotFirstState) { HmiState::STATE_ID_PHONE_CALL, &ApplicationImpl::AddHMIState); HmiStatePtr state2 = TestAddHmiState(HMILevel::HMI_NONE, - HmiState::STATE_ID_NAVI_STREAMING, + HmiState::STATE_ID_VIDEO_STREAMING, &ApplicationImpl::AddHMIState); HmiStatePtr state3 = TestAddHmiState(HMILevel::HMI_LIMITED, HmiState::STATE_ID_TTS_SESSION, @@ -251,7 +251,7 @@ TEST_F(ApplicationImplTest, AddStates_RemoveFirstState) { &ApplicationImpl::AddHMIState); // Second state TestAddHmiState(HMILevel::HMI_NONE, - HmiState::STATE_ID_NAVI_STREAMING, + HmiState::STATE_ID_VIDEO_STREAMING, &ApplicationImpl::AddHMIState); HmiStatePtr state3 = TestAddHmiState(HMILevel::HMI_LIMITED, HmiState::STATE_ID_TTS_SESSION, @@ -270,7 +270,7 @@ TEST_F(ApplicationImplTest, AddStates_RemoveFirstState) { TEST_F(ApplicationImplTest, SetRegularState_RemoveFirstState) { HmiStatePtr state1 = TestAddHmiState(HMILevel::HMI_NONE, - HmiState::STATE_ID_NAVI_STREAMING, + HmiState::STATE_ID_VIDEO_STREAMING, &ApplicationImpl::AddHMIState); // Set regular state HmiStatePtr state2 = TestAddHmiState(HMILevel::HMI_FULL, @@ -321,7 +321,7 @@ TEST_F(ApplicationImplTest, AddStateAddRegularState_GetHmiLvlAudioSystemState) { audiostate = AudioStreamingState::AUDIBLE; syst_context = SystemContext::SYSCTXT_MENU; TestAddHmiState(HMILevel::HMI_LIMITED, - HmiState::STATE_ID_NAVI_STREAMING, + HmiState::STATE_ID_VIDEO_STREAMING, &ApplicationImpl::AddHMIState); EXPECT_EQ(test_lvl, app_impl->hmi_level()); 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 c922c227bb..9cc552f188 100644 --- a/src/components/application_manager/test/application_manager_impl_test.cc +++ b/src/components/application_manager/test/application_manager_impl_test.cc @@ -89,6 +89,9 @@ namespace { const std::string kDirectoryName = "./test_storage"; const uint32_t kTimeout = 10000u; connection_handler::DeviceHandle kDeviceId = 12345u; +const std::string kAppId = "someID"; +const uint32_t kConnectionKey = 1232u; +const std::string kAppName = "appName"; } // namespace class ApplicationManagerImplTest : public ::testing::Test { @@ -136,6 +139,8 @@ class ApplicationManagerImplTest : public ::testing::Test { .WillByDefault(Return(stop_streaming_timeout)); ON_CALL(mock_application_manager_settings_, default_timeout()) .WillByDefault(ReturnRef(kTimeout)); + ON_CALL(mock_application_manager_settings_, + application_list_update_timeout()).WillByDefault(Return(kTimeout)); app_manager_impl_.reset(new am::ApplicationManagerImpl( mock_application_manager_settings_, mock_policy_settings_)); @@ -941,6 +946,49 @@ TEST_F(ApplicationManagerImplTest, UnregisterAnotherAppDuringAudioPassThru) { } } +TEST_F(ApplicationManagerImplTest, + RegisterApplication_PathToTheIconExists_IconWasSet) { + file_system::CreateDirectory(kDirectoryName); + const std::string full_icon_path = kDirectoryName + "/" + kAppId; + ASSERT_TRUE(file_system::CreateFile(full_icon_path)); + + smart_objects::SmartObject request_for_registration( + smart_objects::SmartType_Map); + + smart_objects::SmartObject& params = + request_for_registration[strings::msg_params]; + params[strings::app_id] = kAppId; + params[strings::language_desired] = mobile_api::Language::EN_US; + params[strings::hmi_display_language_desired] = mobile_api::Language::EN_US; + + request_for_registration[strings::params][strings::connection_key] = + kConnectionKey; + request_for_registration[strings::msg_params][strings::app_name] = kAppName; + request_for_registration[strings::msg_params][strings::sync_msg_version] + [strings::minor_version] = APIVersion::kAPIV2; + request_for_registration[strings::msg_params][strings::sync_msg_version] + [strings::major_version] = APIVersion::kAPIV3; + + request_for_registration[strings::params][strings::protocol_version] = + protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2; + + smart_objects::SmartObjectSPtr request_for_registration_ptr = + MakeShared<smart_objects::SmartObject>(request_for_registration); + + ApplicationSharedPtr application = + app_manager_impl_->RegisterApplication(request_for_registration_ptr); + EXPECT_STREQ(kAppName.c_str(), application->name().c_str()); + EXPECT_STREQ(full_icon_path.c_str(), application->app_icon_path().c_str()); + EXPECT_EQ(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_2, + application->protocol_version()); + EXPECT_EQ(APIVersion::kAPIV2, + application->version().min_supported_api_version); + EXPECT_EQ(APIVersion::kAPIV3, + application->version().max_supported_api_version); + + EXPECT_TRUE(file_system::RemoveDirectory(kDirectoryName, true)); +} + } // application_manager_test } // namespace components } // namespace test diff --git a/src/components/application_manager/test/application_state_test.cc b/src/components/application_manager/test/application_state_test.cc index 33f23022f0..6f732b6adc 100644 --- a/src/components/application_manager/test/application_state_test.cc +++ b/src/components/application_manager/test/application_state_test.cc @@ -58,7 +58,7 @@ std::vector<StateID> GenerateCurrentStates() { states.push_back(StateID::STATE_ID_SAFETY_MODE); states.push_back(StateID::STATE_ID_VR_SESSION); states.push_back(StateID::STATE_ID_TTS_SESSION); - states.push_back(StateID::STATE_ID_NAVI_STREAMING); + states.push_back(StateID::STATE_ID_VIDEO_STREAMING); states.push_back(StateID::STATE_ID_DEACTIVATE_HMI); return states; } diff --git a/src/components/application_manager/test/commands/CMakeLists.txt b/src/components/application_manager/test/commands/CMakeLists.txt index 8dafc16471..be236fdb49 100644 --- a/src/components/application_manager/test/commands/CMakeLists.txt +++ b/src/components/application_manager/test/commands/CMakeLists.txt @@ -65,6 +65,7 @@ set(LIBRARIES AMMobileCommandsLibrary connectionHandler jsoncpp + Policy ) create_cotired_test("commands_test" "${SOURCES}" "${LIBRARIES}" ) diff --git a/src/components/application_manager/test/commands/hmi/activate_app_request_test.cc b/src/components/application_manager/test/commands/hmi/activate_app_request_test.cc index 7f7911a01d..ff309d444a 100644 --- a/src/components/application_manager/test/commands/hmi/activate_app_request_test.cc +++ b/src/components/application_manager/test/commands/hmi/activate_app_request_test.cc @@ -105,8 +105,7 @@ TEST_F(ActivateAppRequestTest, Run_SUCCESS) { EXPECT_CALL(app_mngr_, SendMessageToHMI(CheckMessage(mobile_apis::HMILevel::HMI_FULL))); #else - EXPECT_CALL(app_mngr_, - SendMessageToHMI(msg))); + EXPECT_CALL(app_mngr_, SendMessageToHMI(msg)); #endif command->Run(); diff --git a/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc b/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc index ffedf1b4f6..4b805f4006 100644 --- a/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc +++ b/src/components/application_manager/test/commands/hmi/hmi_notifications/hmi_notifications_test.cc @@ -1191,6 +1191,7 @@ TEST_F(HMICommandsNotificationsTest, SetRegularState(app_, mobile_apis::HMILevel::HMI_NONE, mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, false)); command->Run(); } @@ -1219,6 +1220,7 @@ TEST_F(HMICommandsNotificationsTest, SetRegularState(app_, mobile_apis::HMILevel::HMI_NONE, mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, false)); command->Run(); } diff --git a/src/components/application_manager/test/commands/hmi/ui_get_capabilities_response_test.cc b/src/components/application_manager/test/commands/hmi/ui_get_capabilities_response_test.cc index b02c9851ee..7dd7a74f4c 100644 --- a/src/components/application_manager/test/commands/hmi/ui_get_capabilities_response_test.cc +++ b/src/components/application_manager/test/commands/hmi/ui_get_capabilities_response_test.cc @@ -95,6 +95,8 @@ TEST_F(UIGetCapabilitiesResponseTest, RUN_SetDisplay_SUCCESSS) { smart_objects::SmartObject(smart_objects::SmartType_Map); (*command_msg)[strings::msg_params][hmi_response::display_capabilities] [hmi_response::display_type] = "GEN2_8_DMA"; + (*command_msg)[strings::msg_params][hmi_response::display_capabilities] + [hmi_response::display_name] = "GENERIC_DISPLAY"; ResponseFromHMIPtr command( CreateCommand<UIGetCapabilitiesResponse>(command_msg)); diff --git a/src/components/application_manager/test/commands/mobile/alert_request_test.cc b/src/components/application_manager/test/commands/mobile/alert_request_test.cc index 5d9e507511..f4ad62f29a 100644 --- a/src/components/application_manager/test/commands/mobile/alert_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/alert_request_test.cc @@ -382,6 +382,12 @@ TEST_F(AlertRequestTest, Run_SUCCESS) { SubscribeApplicationToSoftButton( (*msg_)[am::strings::msg_params], _, kFunctionId)); + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + ExpectManageHmiCommandTTSAndUI(); CommandPtr command(CreateCommand<AlertRequest>(msg_)); command->Run(); @@ -435,6 +441,11 @@ TEST_F(AlertRequestTest, OnEvent_UIAlertHasHmiResponsesToWait_UNSUCCESS) { EXPECT_CALL(mock_message_helper_, ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); ExpectManageHmiCommandTTSAndUI(); @@ -465,6 +476,12 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSWarnings_SUCCESS) { .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + EXPECT_CALL( app_mngr_, ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))) .WillOnce(Return(true)); @@ -492,6 +509,11 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSUnsupportedResource_SUCCESS) { ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( app_mngr_, ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))) .WillOnce(Return(true)); @@ -524,6 +546,11 @@ TEST_F(AlertRequestTest, EXPECT_CALL(mock_message_helper_, ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton( (*msg_)[am::strings::msg_params], _, kFunctionId)); @@ -566,6 +593,11 @@ TEST_F(AlertRequestTest, OnEvent_TTSUnsupportedResourceUiAlertSuccess_SUCCESS) { EXPECT_CALL(mock_message_helper_, ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(mock_message_helper_, SubscribeApplicationToSoftButton( (*msg_)[am::strings::msg_params], _, kFunctionId)); @@ -611,6 +643,11 @@ TEST_F(AlertRequestTest, OnEvent_TTSSuccesUiAlertInvalidEnum_SUCCESS) { ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( app_mngr_, ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))) .WillOnce(Return(true)); @@ -656,6 +693,11 @@ TEST_F(AlertRequestTest, DISABLED_OnEvent_TTSAbortedUiAlertNotSent_SUCCESS) { ProcessSoftButtons((*msg_)[am::strings::msg_params], _, _, _)) .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( app_mngr_, ManageHMICommand(HMIResultCodeIs(hmi_apis::FunctionID::TTS_Speak))) .WillOnce(Return(true)); diff --git a/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc b/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc index 7840e35cec..60af9381e8 100644 --- a/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc +++ b/src/components/application_manager/test/commands/mobile/on_system_request_notification_test.cc @@ -54,6 +54,7 @@ using application_manager::commands::CommandImpl; using application_manager::MockMessageHelper; using test::components::policy_test::MockPolicyHandlerInterface; using namespace mobile_apis; +using testing::SaveArg; using testing::Mock; using testing::Return; using testing::ReturnRef; @@ -61,17 +62,35 @@ using testing::_; namespace { const uint32_t kConnectionKey = 1u; +const std::string kPolicyAppId = "fake-app-id"; } // namespace class OnSystemRequestNotificationTest - : public CommandsTest<CommandsTestMocks::kIsNice> {}; + : public CommandsTest<CommandsTestMocks::kIsNice> { + public: + OnSystemRequestNotificationTest() : mock_app_(CreateMockApp()) {} + + void PreConditions() { + ON_CALL(app_mngr_, application(kConnectionKey)) + .WillByDefault(Return(mock_app_)); + + ON_CALL(app_mngr_, GetPolicyHandler()) + .WillByDefault(ReturnRef(mock_policy_handler_)); + ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kPolicyAppId)); + } + + protected: + MockAppPtr mock_app_; + MockPolicyHandlerInterface mock_policy_handler_; +}; TEST_F(OnSystemRequestNotificationTest, Run_ProprietaryType_SUCCESS) { - const RequestType::eType kRequestType = RequestType::PROPRIETARY; + const mobile_apis::RequestType::eType request_type = + mobile_apis::RequestType::PROPRIETARY; MessageSharedPtr msg = CreateMessage(); (*msg)[strings::params][strings::connection_key] = kConnectionKey; - (*msg)[strings::msg_params][strings::request_type] = kRequestType; + (*msg)[strings::msg_params][strings::request_type] = request_type; SharedPtr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); @@ -111,11 +130,12 @@ TEST_F(OnSystemRequestNotificationTest, Run_ProprietaryType_SUCCESS) { } TEST_F(OnSystemRequestNotificationTest, Run_HTTPType_SUCCESS) { - const RequestType::eType kRequestType = RequestType::HTTP; + const mobile_apis::RequestType::eType request_type = + mobile_apis::RequestType::HTTP; MessageSharedPtr msg = CreateMessage(); (*msg)[strings::params][strings::connection_key] = kConnectionKey; - (*msg)[strings::msg_params][strings::request_type] = kRequestType; + (*msg)[strings::msg_params][strings::request_type] = request_type; SharedPtr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); @@ -148,11 +168,12 @@ TEST_F(OnSystemRequestNotificationTest, Run_HTTPType_SUCCESS) { } TEST_F(OnSystemRequestNotificationTest, Run_InvalidApp_NoNotification) { - const RequestType::eType kRequestType = RequestType::HTTP; + const mobile_apis::RequestType::eType request_type = + mobile_apis::RequestType::HTTP; MessageSharedPtr msg = CreateMessage(); (*msg)[strings::params][strings::connection_key] = kConnectionKey; - (*msg)[strings::msg_params][strings::request_type] = kRequestType; + (*msg)[strings::msg_params][strings::request_type] = request_type; SharedPtr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); @@ -172,11 +193,12 @@ TEST_F(OnSystemRequestNotificationTest, Run_InvalidApp_NoNotification) { } TEST_F(OnSystemRequestNotificationTest, Run_RequestNotAllowed_NoNotification) { - const RequestType::eType kRequestType = RequestType::HTTP; + const mobile_apis::RequestType::eType request_type = + mobile_apis::RequestType::HTTP; MessageSharedPtr msg = CreateMessage(); (*msg)[strings::params][strings::connection_key] = kConnectionKey; - (*msg)[strings::msg_params][strings::request_type] = kRequestType; + (*msg)[strings::msg_params][strings::request_type] = request_type; SharedPtr<OnSystemRequestNotification> command = CreateCommand<OnSystemRequestNotification>(msg); @@ -199,6 +221,71 @@ TEST_F(OnSystemRequestNotificationTest, Run_RequestNotAllowed_NoNotification) { command->Run(); } +TEST_F( + OnSystemRequestNotificationTest, + Run_RequestTypeAllowedAndRequestSubTypeDisallowed_MessageNotSentToMobile) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + const auto request_type = mobile_apis::RequestType::HTTP; + (*msg)[strings::msg_params][strings::request_type] = request_type; + const std::string request_subtype = "fakeSubType"; + (*msg)[am::strings::msg_params][am::strings::request_subtype] = + request_subtype; + + PreConditions(); + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kPolicyAppId, request_type)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_policy_handler_, + IsRequestSubTypeAllowed(kPolicyAppId, request_subtype)) + .WillOnce(Return(false)); + + EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _)).Times(0); + + auto command = CreateCommand<OnSystemRequestNotification>(msg); + + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(OnSystemRequestNotificationTest, + Run_RequestTypeAllowedAndRequestSubTypeAllowed_SendMessageToMobile) { + MessageSharedPtr msg = CreateMessage(); + (*msg)[strings::params][strings::connection_key] = kConnectionKey; + const auto request_type = mobile_apis::RequestType::OEM_SPECIFIC; + (*msg)[strings::msg_params][strings::request_type] = request_type; + const std::string request_subtype = "fakeSubType"; + (*msg)[am::strings::msg_params][am::strings::request_subtype] = + request_subtype; + + PreConditions(); + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kPolicyAppId, request_type)) + .WillOnce(Return(true)); + EXPECT_CALL(mock_policy_handler_, + IsRequestSubTypeAllowed(kPolicyAppId, request_subtype)) + .WillOnce(Return(true)); + + smart_objects::SmartObjectSPtr result; + EXPECT_CALL(app_mngr_, SendMessageToMobile(_, _)) + .WillOnce((SaveArg<0>(&result))); + + auto command = CreateCommand<OnSystemRequestNotification>(msg); + + ASSERT_TRUE(command->Init()); + command->Run(); + + EXPECT_EQ(application_manager::MessageType::kNotification, + (*result)[strings::params][strings::message_type].asInt()); + EXPECT_EQ(request_type, + (*result)[strings::msg_params][strings::request_type].asInt()); + EXPECT_EQ( + request_subtype, + (*result)[strings::msg_params][strings::request_subtype].asString()); +} + } // namespace on_system_request_notification } // namespace mobile_commands_test } // namespace commands_test diff --git a/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc b/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc index a27bac970c..ad15dca7eb 100644 --- a/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc +++ b/src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc @@ -247,6 +247,12 @@ TEST_F(PerformAudioPassThruRequestTest, ManageMobileCommand(_, am::commands::Command::CommandOrigin::ORIGIN_SDL)) .WillOnce(DoAll(SaveArg<0>(&response_to_mobile), Return(true))); + EXPECT_CALL(mock_message_helper_, + VerifyTtsFiles((*mobile_request)[am::strings::msg_params] + [am::strings::initial_prompt], + _, + _)).WillOnce(Return(mobile_apis::Result::SUCCESS)); + command->Run(); command->on_event(event_tts); command->on_event(event_ui); @@ -320,6 +326,10 @@ TEST_F(PerformAudioPassThruRequestTest, kCorrectPrompt; msg_params_[am::strings::initial_prompt][0][am::strings::type] = kCorrectType; + EXPECT_CALL(mock_message_helper_, + VerifyTtsFiles(msg_params_[am::strings::initial_prompt], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + MessageSharedPtr speak_reqeust_result_msg; MessageSharedPtr perform_result_msg; { @@ -405,6 +415,10 @@ TEST_F(PerformAudioPassThruRequestTest, msg_params_[am::strings::audio_pass_display_text1] = kCorrectDisplayText1; msg_params_[am::strings::audio_pass_display_text2] = kCorrectDisplayText2; + EXPECT_CALL(mock_message_helper_, + VerifyTtsFiles(msg_params_[am::strings::initial_prompt], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + MessageSharedPtr speak_reqeust_result_msg; MessageSharedPtr perform_result_msg; { @@ -469,6 +483,10 @@ TEST_F(PerformAudioPassThruRequestTest, kCorrectPrompt; msg_params_[am::strings::initial_prompt][0][am::strings::type] = kCorrectType; + EXPECT_CALL(mock_message_helper_, + VerifyTtsFiles(msg_params_[am::strings::initial_prompt], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + const bool muted = false; msg_params_[am::strings::mute_audio] = muted; @@ -743,6 +761,11 @@ TEST_F(PerformAudioPassThruRequestTest, msg_params_[am::strings::initial_prompt][0][am::strings::text] = kCorrectPrompt; msg_params_[am::strings::initial_prompt][0][am::strings::type] = kCorrectType; + + EXPECT_CALL(mock_message_helper_, + VerifyTtsFiles(msg_params_[am::strings::initial_prompt], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + MessageSharedPtr speak_reqeust_result_msg; MessageSharedPtr perform_result_msg; ON_CALL(app_mngr_, GetNextHMICorrelationID()) diff --git a/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc b/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc index b7a004f199..3225b4ef4c 100644 --- a/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/register_app_interface_request_test.cc @@ -161,6 +161,12 @@ class RegisterAppInterfaceRequestTest .WillByDefault(ReturnRef(kDummyDiagModes)); ON_CALL(mock_policy_handler_, GetAppRequestTypes(_)) .WillByDefault(Return(std::vector<std::string>())); + ON_CALL(mock_policy_handler_, GetAppRequestTypeState(_)) + .WillByDefault(Return(policy::RequestType::State::EMPTY)); + ON_CALL(mock_policy_handler_, GetAppRequestSubTypes(_)) + .WillByDefault(Return(std::vector<std::string>())); + ON_CALL(mock_policy_handler_, GetAppRequestSubTypeState(_)) + .WillByDefault(Return(policy::RequestSubType::State::EMPTY)); ON_CALL(mock_policy_handler_, GetUserConsentForDevice(_)) .WillByDefault(Return(policy::DeviceConsent::kDeviceAllowed)); ON_CALL(app_mngr_, GetDeviceTransportType(_)) @@ -344,6 +350,7 @@ TEST_F(RegisterAppInterfaceRequestTest, SmartObject& display_capabilities = (*expected_message)[am::hmi_response::display_capabilities]; display_capabilities[am::hmi_response::display_type] = "test_display_type"; + display_capabilities[am::hmi_response::display_name] = "GENERIC_DISPLAY"; display_capabilities[am::hmi_response::text_fields] = "test_text_fields"; display_capabilities[am::hmi_response::image_fields] = "test_image_fields"; display_capabilities[am::hmi_response::media_clock_formats] = diff --git a/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc b/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc index b278479df8..a5d50502f4 100644 --- a/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc +++ b/src/components/application_manager/test/commands/mobile/set_app_icon_test.cc @@ -40,6 +40,8 @@ #include "application_manager/commands/command_request_test.h" #include "application_manager/mock_application.h" #include "application_manager/mock_application_manager.h" +#include "protocol_handler/mock_protocol_handler.h" +#include "protocol_handler/mock_protocol_handler_settings.h" #include "application_manager/mock_message_helper.h" #include "application_manager/event_engine/event.h" #include "application_manager/mock_hmi_interface.h" @@ -55,6 +57,9 @@ using am::commands::SetAppIconRequest; using am::commands::CommandImpl; using am::commands::MessageSharedPtr; using am::MockMessageHelper; +using am::MockHmiInterfaces; +using test::components::protocol_handler_test::MockProtocolHandler; +using test::components::protocol_handler_test::MockProtocolHandlerSettings; using ::utils::SharedPtr; using ::testing::_; using ::testing::Return; @@ -88,6 +93,10 @@ class SetAppIconRequestTest return msg; } + NiceMock<MockHmiInterfaces> hmi_interfaces_; + protocol_handler_test::MockProtocolHandler mock_protocol_handler_; + protocol_handler_test::MockProtocolHandlerSettings + mock_protocol_handler_settings_; }; TEST_F(SetAppIconRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) { @@ -107,6 +116,20 @@ TEST_F(SetAppIconRequestTest, OnEvent_UI_UNSUPPORTED_RESOURCE) { MockAppPtr mock_app = CreateMockApp(); ON_CALL(app_mngr_, application(kConnectionKey)) .WillByDefault(Return(mock_app)); + ON_CALL(app_mngr_, hmi_interfaces()) + .WillByDefault(ReturnRef(hmi_interfaces_)); + ON_CALL(hmi_interfaces_, + GetInterfaceState(am::HmiInterfaces::HMI_INTERFACE_UI)) + .WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE)); + + ON_CALL(app_mngr_, protocol_handler()) + .WillByDefault(ReturnRef(mock_protocol_handler_)); + ON_CALL(mock_protocol_handler_, get_settings()) + .WillByDefault(ReturnRef(mock_protocol_handler_settings_)); + + ON_CALL(mock_protocol_handler_settings_, max_supported_protocol_version()) + .WillByDefault( + Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4)); ON_CALL(*mock_app, app_id()).WillByDefault(Return(kConnectionKey)); ON_CALL(*mock_app, set_app_icon_path(_)).WillByDefault(Return(true)); diff --git a/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc b/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc index 641e5636a9..9ed459f799 100644 --- a/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc +++ b/src/components/application_manager/test/commands/mobile/set_global_properties_test.cc @@ -154,6 +154,10 @@ class SetGlobalPropertiesRequestTest EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(help_prompt, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(timeout_prompt, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); SmartObject vr_help_title("title"); @@ -288,6 +292,12 @@ TEST_F(SetGlobalPropertiesRequestTest, ON_CALL(mock_message_helper_, VerifyImage(_, _, _)) .WillByDefault(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*msg_vr)[am::strings::msg_params][am::strings::help_prompt], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + (*msg_vr)[am::strings::params][am::hmi_response::code] = hmi_apis::Common_Result::SUCCESS; Event event_vr(hmi_apis::FunctionID::TTS_SetGlobalProperties); @@ -763,6 +773,10 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSHelpAndTimeout_SUCCESS) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(help_prompt, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(timeout_prompt, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); SmartObject vr_help_title("title"); EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); @@ -795,6 +809,8 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyHelp_SUCCESS) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(help_prompt, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); SmartObject vr_help_title("title"); EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); @@ -825,6 +841,8 @@ TEST_F(SetGlobalPropertiesRequestTest, Run_TTSOnlyTimeout_SUCCESS) { EXPECT_CALL(app_mngr_, application(kConnectionKey)) .WillOnce(Return(mock_app_)); EXPECT_CALL(mock_message_helper_, VerifyImageVrHelpItems(_, _, _)).Times(0); + EXPECT_CALL(mock_message_helper_, VerifyTtsFiles(timeout_prompt, _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); EXPECT_CALL(app_mngr_, RemoveAppFromTTSGlobalPropertiesList(kConnectionKey)); SmartObject vr_help_title("title"); EXPECT_CALL(*mock_app_, vr_help_title()).WillOnce(Return(&vr_help_title)); diff --git a/src/components/application_manager/test/commands/mobile/speak_request_test.cc b/src/components/application_manager/test/commands/mobile/speak_request_test.cc index f07012d315..36a9b85c6a 100644 --- a/src/components/application_manager/test/commands/mobile/speak_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/speak_request_test.cc @@ -286,6 +286,11 @@ TEST_F(SpeakRequestTest, Run_MsgWithEmptyString_Success) { [am::strings::text] = ""; CommandPtr command(CreateCommand<SpeakRequest>(request_)); + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*request_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_)); ON_CALL(*app_, app_id()).WillByDefault(Return(kAppId)); @@ -301,6 +306,11 @@ TEST_F(SpeakRequestTest, Run_MsgCorrect_Success) { [am::strings::text] = "asda"; CommandPtr command(CreateCommand<SpeakRequest>(request_)); + EXPECT_CALL( + mock_message_helper_, + VerifyTtsFiles( + (*request_)[am::strings::msg_params][am::strings::tts_chunks], _, _)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); ON_CALL(app_mngr_, application(_)).WillByDefault(Return(app_)); ON_CALL(*app_, app_id()).WillByDefault(Return(kAppId)); diff --git a/src/components/application_manager/test/commands/mobile/system_request_test.cc b/src/components/application_manager/test/commands/mobile/system_request_test.cc index 0e07889b4b..219ac54a8e 100644 --- a/src/components/application_manager/test/commands/mobile/system_request_test.cc +++ b/src/components/application_manager/test/commands/mobile/system_request_test.cc @@ -56,11 +56,14 @@ using am::commands::CommandImpl; using am::commands::MessageSharedPtr; using am::MockHmiInterfaces; using am::event_engine::Event; +using am::MessageType; using policy_test::MockPolicyHandlerInterface; using ::utils::SharedPtr; using ::testing::_; +using ::testing::DoAll; using ::testing::Return; using ::testing::ReturnRef; +using ::testing::SaveArg; namespace { const uint32_t kConnectionKey = 2u; @@ -70,6 +73,7 @@ const std::string kAppFolderName = "fake-app-name"; const std::string kAppStorageFolder = "fake-storage"; const std::string kSystemFilesPath = "/fake/system/files"; const std::string kFileName = "Filename"; +const uint32_t kHmiAppId = 3u; } // namespace class SystemRequestTest @@ -96,6 +100,7 @@ class SystemRequestTest ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey)); ON_CALL(*mock_app_, policy_app_id()).WillByDefault(Return(kAppPolicyId)); ON_CALL(*mock_app_, folder_name()).WillByDefault(Return(kAppFolderName)); + ON_CALL(*mock_app_, hmi_app_id()).WillByDefault(Return(kHmiAppId)); ON_CALL(app_mngr_settings_, system_files_path()) .WillByDefault(ReturnRef(kSystemFilesPath)); @@ -128,6 +133,105 @@ TEST_F(SystemRequestTest, Run_HTTP_FileName_no_binary_data_REJECTED) { command->Run(); } +TEST_F(SystemRequestTest, + Run_RequestTypeAllowedAndRequestSubTypeAllowed_SendHMIRequest) { + MessageSharedPtr msg = CreateIVSUMessage(); + + (*msg)[am::strings::msg_params][am::strings::request_type] = + mobile_apis::RequestType::OEM_SPECIFIC; + + const std::string request_subtype = "fakeSubType"; + (*msg)[am::strings::msg_params][am::strings::request_subtype] = + request_subtype; + + const std::vector<uint8_t> binary_data = {1u, 2u}; + (*msg)[am::strings::params][am::strings::binary_data] = binary_data; + + PreConditions(); + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kAppPolicyId, + mobile_apis::RequestType::OEM_SPECIFIC)) + .WillOnce(Return(true)); + + EXPECT_CALL(mock_policy_handler_, + IsRequestSubTypeAllowed(kAppPolicyId, request_subtype)) + .WillOnce(Return(true)); + + EXPECT_CALL(app_mngr_, + SaveBinary(binary_data, kSystemFilesPath, kFileName, 0u)) + .WillOnce(Return(mobile_apis::Result::SUCCESS)); + + smart_objects::SmartObjectSPtr result; + EXPECT_CALL(app_mngr_, ManageHMICommand(_)) + .WillOnce(DoAll(SaveArg<0>(&result), Return(true))); + + SharedPtr<SystemRequest> command(CreateCommand<SystemRequest>(msg)); + ASSERT_TRUE(command->Init()); + command->Run(); + + EXPECT_EQ(MessageType::kRequest, + (*result)[am::strings::params][am::strings::message_type].asInt()); + EXPECT_EQ( + mobile_apis::RequestType::OEM_SPECIFIC, + (*result)[am::strings::msg_params][am::strings::request_type].asInt()); + EXPECT_EQ( + request_subtype, + (*msg)[am::strings::msg_params][am::strings::request_subtype].asString()); +} + +TEST_F( + SystemRequestTest, + Run_RequestTypeAllowedAndRequestSubTypeDisallowed_SendDisallowedResponse) { + MessageSharedPtr msg = CreateIVSUMessage(); + + (*msg)[am::strings::msg_params][am::strings::request_type] = + mobile_apis::RequestType::OEM_SPECIFIC; + + const std::string request_subtype = "fakeSubType2"; + (*msg)[am::strings::msg_params][am::strings::request_subtype] = + request_subtype; + + PreConditions(); + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kAppPolicyId, + mobile_apis::RequestType::OEM_SPECIFIC)) + .WillOnce(Return(true)); + + EXPECT_CALL(mock_policy_handler_, + IsRequestSubTypeAllowed(kAppPolicyId, request_subtype)) + .WillOnce(Return(false)); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::DISALLOWED); + EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0); + + SharedPtr<SystemRequest> command(CreateCommand<SystemRequest>(msg)); + ASSERT_TRUE(command->Init()); + command->Run(); +} + +TEST_F(SystemRequestTest, Run_RequestTypeDisallowed_SendDisallowedResponse) { + MessageSharedPtr msg = CreateIVSUMessage(); + + (*msg)[am::strings::msg_params][am::strings::request_type] = + mobile_apis::RequestType::OEM_SPECIFIC; + + PreConditions(); + + EXPECT_CALL(mock_policy_handler_, + IsRequestTypeAllowed(kAppPolicyId, + mobile_apis::RequestType::OEM_SPECIFIC)) + .WillOnce(Return(false)); + + ExpectManageMobileCommandWithResultCode(mobile_apis::Result::DISALLOWED); + EXPECT_CALL(app_mngr_, ManageHMICommand(_)).Times(0); + + SharedPtr<SystemRequest> command(CreateCommand<SystemRequest>(msg)); + ASSERT_TRUE(command->Init()); + command->Run(); +} + } // namespace system_request } // namespace mobile_commands_test } // namespace commands_test diff --git a/src/components/application_manager/test/hmi_capabilities.json b/src/components/application_manager/test/hmi_capabilities.json index 0efcc688bc..1c024f2669 100644 --- a/src/components/application_manager/test/hmi_capabilities.json +++ b/src/components/application_manager/test/hmi_capabilities.json @@ -42,6 +42,7 @@ ], "displayCapabilities": { "displayType": "GEN2_8_DMA", + "displayName": "GENERIC_DISPLAY", "textFields": [ { "name": "mainField1", @@ -215,7 +216,9 @@ "imageFields": [ { "name": "softButtonImage", - "imageTypeSupported": [], + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -223,7 +226,9 @@ }, { "name": "choiceImage", - "imageTypeSupported": [], + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -231,7 +236,9 @@ }, { "name": "choiceSecondaryImage", - "imageTypeSupported": [], + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -239,7 +246,9 @@ }, { "name": "menuIcon", - "imageTypeSupported": [], + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -247,7 +256,9 @@ }, { "name": "cmdIcon", - "imageTypeSupported": [], + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -255,7 +266,9 @@ }, { "name": "appIcon", - "imageTypeSupported": [], + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -263,7 +276,9 @@ }, { "name": "graphic", - "imageTypeSupported": [], + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 @@ -271,7 +286,9 @@ }, { "name": "secondaryGraphic", - "imageTypeSupported": [], + "imageTypeSupported": [ + "GRAPHIC_PNG" + ], "imageResolution": { "resolutionWidth": 35, "resolutionHeight": 35 diff --git a/src/components/application_manager/test/hmi_capabilities_test.cc b/src/components/application_manager/test/hmi_capabilities_test.cc index b8369528aa..d4f2b954cc 100644 --- a/src/components/application_manager/test/hmi_capabilities_test.cc +++ b/src/components/application_manager/test/hmi_capabilities_test.cc @@ -186,6 +186,8 @@ TEST_F(HMICapabilitiesTest, LoadCapabilitiesFromFile) { if (file_system::FileExists("./app_info_data")) { EXPECT_TRUE(::file_system::DeleteFile("./app_info_data")); } + EXPECT_CALL(app_mngr_, IsSOStructValid(_, _)).WillOnce(Return(true)); + EXPECT_TRUE(hmi_capabilities_test->LoadCapabilitiesFromFile()); // Check active languages @@ -269,6 +271,9 @@ TEST_F(HMICapabilitiesTest, LoadCapabilitiesFromFile) { static_cast<hmi_apis::Common_DisplayType::eType>( display_capabilities_so[hmi_response::display_type].asInt())); + EXPECT_EQ("GENERIC_DISPLAY", + display_capabilities_so[hmi_response::display_name].asString()); + EXPECT_TRUE(display_capabilities_so["graphicSupported"].asBool()); // Check text fields @@ -562,6 +567,7 @@ TEST_F(HMICapabilitiesTest, TEST_F(HMICapabilitiesTest, VerifyImageType) { const int32_t image_type = 1; smart_objects::SmartObject sm_obj; + EXPECT_CALL(app_mngr_, IsSOStructValid(_, _)).WillOnce(Return(true)); sm_obj[hmi_response::image_capabilities][0] = image_type; hmi_capabilities_test->set_display_capabilities(sm_obj); 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 c46a0b994f..5bc4ef6a42 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 @@ -106,6 +106,8 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(system_context, const mobile_apis::SystemContext::eType()); MOCK_CONST_METHOD0(audio_streaming_state, const mobile_apis::AudioStreamingState::eType()); + MOCK_CONST_METHOD0(video_streaming_state, + const mobile_apis::VideoStreamingState::eType()); MOCK_CONST_METHOD0(app_icon_path, const std::string&()); MOCK_CONST_METHOD0(device, connection_handler::DeviceHandle()); MOCK_CONST_METHOD0(CurrentHmiState, const application_manager::HmiStatePtr()); @@ -170,6 +172,7 @@ class MockApplication : public ::application_manager::Application { MOCK_METHOD1(IsSubscribedToSoftButton, bool(const uint32_t softbutton_id)); MOCK_METHOD1(UnsubscribeFromSoftButtons, void(int32_t cmd_id)); MOCK_CONST_METHOD0(IsAudioApplication, bool()); + MOCK_CONST_METHOD0(IsVideoApplication, bool()); MOCK_METHOD0(LoadPersistentFiles, void()); // InitialApplicationData methods MOCK_CONST_METHOD0(app_types, const smart_objects::SmartObject*()); 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 93db0d9795..e8a969718d 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 @@ -176,6 +176,10 @@ class MockMessageHelper { MOCK_METHOD1(SendGlobalPropertiesToHMI, void(ApplicationConstSharedPtr app)); MOCK_METHOD1(GetIVISubscriptionRequests, smart_objects::SmartObjectList(ApplicationSharedPtr app)); + MOCK_METHOD3(VerifyTtsFiles, + mobile_apis::Result::eType(smart_objects::SmartObject& message, + ApplicationConstSharedPtr app, + ApplicationManager& app_mngr)); MOCK_METHOD3(VerifyImageFiles, mobile_apis::Result::eType(smart_objects::SmartObject& message, ApplicationConstSharedPtr app, diff --git a/src/components/application_manager/test/mock_message_helper.cc b/src/components/application_manager/test/mock_message_helper.cc index 24bba63e71..8b0ec5b854 100644 --- a/src/components/application_manager/test/mock_message_helper.cc +++ b/src/components/application_manager/test/mock_message_helper.cc @@ -315,6 +315,14 @@ smart_objects::SmartObjectList MessageHelper::GetIVISubscriptionRequests( app); } +mobile_apis::Result::eType MessageHelper::VerifyTtsFiles( + smart_objects::SmartObject& message, + ApplicationConstSharedPtr app, + ApplicationManager& app_mngr) { + return MockMessageHelper::message_helper_mock()->VerifyTtsFiles( + message, app, app_mngr); +} + mobile_apis::Result::eType MessageHelper::VerifyImage( smart_objects::SmartObject& message, ApplicationConstSharedPtr app, diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc index d9e1cefa01..3b6d0a16be 100644 --- a/src/components/application_manager/test/policy_handler_test.cc +++ b/src/components/application_manager/test/policy_handler_test.cc @@ -954,6 +954,7 @@ TEST_F(PolicyHandlerTest, OnPendingPermissionChange_AppLimitedAndRevoked) { SetRegularState(_, mobile_apis::HMILevel::HMI_NONE, mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, true)); EXPECT_CALL(*mock_policy_manager_, GetAppPermissionsChanges(_)) @@ -1377,10 +1378,30 @@ TEST_F(PolicyHandlerTest, IsRequestTypeAllowed) { mobile_apis::RequestType::eType type = mobile_apis::RequestType::eType::EMERGENCY; + + EXPECT_CALL(*mock_policy_manager_, GetAppRequestTypesState(kPolicyAppId_)) + .WillOnce(Return(policy::RequestType::State::AVAILABLE)); + EXPECT_CALL(*mock_policy_manager_, GetAppRequestTypes(kPolicyAppId_)) - .WillOnce(Return(std::vector<std::string>())); + .WillOnce(Return(std::vector<std::string>({"HTTP"}))); + // Act + EXPECT_FALSE(policy_handler_.IsRequestTypeAllowed(kPolicyAppId_, type)); +} + +TEST_F(PolicyHandlerTest, IsRequestSubTypeAllowed) { + // Arrange + EnablePolicyAndPolicyManagerMock(); + + // Check expectations + EXPECT_CALL(*mock_policy_manager_, GetAppRequestSubTypesState(kPolicyAppId_)) + .WillOnce(Return(policy::RequestSubType::State::AVAILABLE)); + EXPECT_CALL(*mock_policy_manager_, GetAppRequestSubTypes(kPolicyAppId_)) + .WillOnce( + Return(std::vector<std::string>({"fakeSubType", "fakeSubType2"}))); + // Act - policy_handler_.IsRequestTypeAllowed(kPolicyAppId_, type); + const std::string subtype = "fakeSubType"; + EXPECT_TRUE(policy_handler_.IsRequestSubTypeAllowed(kPolicyAppId_, subtype)); } TEST_F(PolicyHandlerTest, GetVehicleInfo) { diff --git a/src/components/application_manager/test/resumption/resumption_data_db_test.cc b/src/components/application_manager/test/resumption/resumption_data_db_test.cc index 001e06ca58..3b2c0d7b13 100644 --- a/src/components/application_manager/test/resumption/resumption_data_db_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_db_test.cc @@ -271,6 +271,10 @@ void ResumptionDataDBTest::CheckGlobalProportiesData() { select_image.GetInteger(0)); EXPECT_EQ((*menu_icon_)[am::strings::value].asString(), select_image.GetString(1)); + if ((*menu_icon_).keyExists(am::strings::is_template)) { + EXPECT_EQ((*menu_icon_)[am::strings::is_template].asBool(), + select_image.GetBoolean(2)); + } } if (!select_globalproperties.IsNull(8)) { utils::dbms::SQLQuery select_tts_chunk(test_db()); 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 65e01b6119..0f90fe978f 100644 --- a/src/components/application_manager/test/resumption/resumption_data_test.cc +++ b/src/components/application_manager/test/resumption/resumption_data_test.cc @@ -381,6 +381,7 @@ void ResumptionDataTest::SetMenuTitleAndIcon() { sm::SmartObject sm_icon; sm_icon[am::strings::value] = "test icon"; sm_icon[am::strings::image_type] = ImageType::STATIC; + sm_icon[am::strings::is_template] = false; sm::SmartObject sm_title; sm_title = "test title"; 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 28a3383086..0ec902085f 100644 --- a/src/components/application_manager/test/resumption_sql_queries_test.cc +++ b/src/components/application_manager/test/resumption_sql_queries_test.cc @@ -197,8 +197,9 @@ class ResumptionSqlQueriesTest : public ::testing::Test { const int64_t glob_prop_key); SQLQuery& FillImageTable(SQLQuery& query, - const int imageType, - const string& value); + const int image_type, + const string& value, + const bool is_template); SQLQuery& FillTableLimitedCharacterListTable( SQLQuery& query, const string& limitedCharacterList); @@ -456,11 +457,13 @@ void ResumptionSqlQueriesTest::CheckSelectQuery(const string& query_to_check, } SQLQuery& ResumptionSqlQueriesTest::FillImageTable(SQLQuery& query, - const int imageType, - const string& value) { + const int image_type, + const string& value, + const bool is_template) { EXPECT_TRUE(query.Prepare(kInsertImage)); - query.Bind(0, imageType); + query.Bind(0, image_type); query.Bind(1, value); + query.Bind(2, is_template); EXPECT_TRUE(query.Exec()); return query; } @@ -802,7 +805,10 @@ TEST_F(ResumptionSqlQueriesTest, kChecksResumptionData_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kSelectCountHMILevel_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -829,7 +835,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountHMILevel_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kSelectHMILevel_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -854,7 +863,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectHMILevel_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kCheckHMIId_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -879,7 +891,10 @@ TEST_F(ResumptionSqlQueriesTest, kCheckHMIId_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kSelectHMIId_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -904,7 +919,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectHMIId_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kSelectCountHMIId_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -930,7 +948,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountHMIId_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kCountHashId_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -956,7 +977,10 @@ TEST_F(ResumptionSqlQueriesTest, kCountHashId_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kSelectHashId_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -990,7 +1014,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectIgnOffTime_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kCheckApplication_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1015,7 +1042,10 @@ TEST_F(ResumptionSqlQueriesTest, kCheckApplication_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kCountApplications_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1032,7 +1062,9 @@ TEST_F(ResumptionSqlQueriesTest, kCountApplications_ExpectDataCorrect) { device_id, key); - key = FillImageTable(temp_query, 1, "tst_img2").LastInsertId(); + key = FillImageTable( + temp_query, 1 /* image_type */, "tst_img2", true /* is_template */) + .LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1056,7 +1088,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectDataForLoadResumeData_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1084,7 +1119,10 @@ TEST_F(ResumptionSqlQueriesTest, TEST_F(ResumptionSqlQueriesTest, kUpdateHMILevel_ExpectDataUpdated) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1117,7 +1155,10 @@ TEST_F(ResumptionSqlQueriesTest, kUpdateHMILevel_ExpectDataUpdated) { TEST_F(ResumptionSqlQueriesTest, kUpdateIgnOffCount_ExpectDataUpdated) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1148,7 +1189,10 @@ TEST_F(ResumptionSqlQueriesTest, kUpdateIgnOffCount_ExpectDataUpdated) { TEST_F(ResumptionSqlQueriesTest, kCountApplicationsIgnOff_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1189,7 +1233,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectApplicationsIgnOffCount_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1229,7 +1276,10 @@ TEST_F(ResumptionSqlQueriesTest, TEST_F(ResumptionSqlQueriesTest, kUpdateSuspendData_ExpectDataUpdated) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1258,7 +1308,10 @@ TEST_F(ResumptionSqlQueriesTest, kUpdateSuspendData_ExpectDataUpdated) { TEST_F(ResumptionSqlQueriesTest, kDeleteFile_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key1 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1288,7 +1341,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteApplicationFilesArray_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key1 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1324,7 +1380,10 @@ TEST_F(ResumptionSqlQueriesTest, TEST_F(ResumptionSqlQueriesTest, kDeleteSubMenu_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1355,7 +1414,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteApplicationSubMenuArray_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key) .LastInsertId(); @@ -1389,7 +1451,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteApplicationSubscriptionsArray_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); key1 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1426,7 +1491,10 @@ TEST_F(ResumptionSqlQueriesTest, TEST_F(ResumptionSqlQueriesTest, kDeleteImageFromCommands_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillCommandTable(temp_query, 1, "tst_menu_name", 1, 2, key1) .LastInsertId(); key1 = FillGlobalPropertiesTable( @@ -1456,7 +1524,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteImageFromCommands_ExpectDataDeleted) { TEST_F(ResumptionSqlQueriesTest, kDeleteVrCommands_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillCommandTable(temp_query, 1, "tst_menu_name", 1, 2, key1) .LastInsertId(); key1 = FillGlobalPropertiesTable( @@ -1490,7 +1561,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteVrCommands_ExpectDataDeleted) { TEST_F(ResumptionSqlQueriesTest, kDeleteCommands_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillCommandTable(temp_query, 1, "tst_menu_name", 1, 2, key1) .LastInsertId(); @@ -1522,7 +1596,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteApplicationCommandsArray_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillCommandTable(temp_query, 1, "tst_menu_name", 1, 2, key1) .LastInsertId(); @@ -1560,7 +1637,10 @@ TEST_F(ResumptionSqlQueriesTest, TEST_F(ResumptionSqlQueriesTest, kDeleteImageFromChoiceSet_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillChoiceTable(temp_query, 2, "tst_menu_name", @@ -1595,7 +1675,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteVrCommandsFromChoiceSet_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillChoiceTable( temp_query, 1, "tst_menu_name", "second_text", "tert_txt", key1) @@ -1638,7 +1721,10 @@ TEST_F(ResumptionSqlQueriesTest, TEST_F(ResumptionSqlQueriesTest, kDeleteChoice_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillChoiceTable( temp_query, 1, "tst_menu_name", "second_text", "tert_txt", key1) @@ -1775,7 +1861,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteImageFromGlobalProperties_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1804,7 +1893,10 @@ TEST_F(ResumptionSqlQueriesTest, TEST_F(ResumptionSqlQueriesTest, kDeletevrHelpItem_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -1834,7 +1926,10 @@ TEST_F(ResumptionSqlQueriesTest, kDeletevrHelpItem_ExpectDataDeleted) { TEST_F(ResumptionSqlQueriesTest, kDeletevrHelpItemArray_ExpectDataDeleted) { // Arrange SQLQuery temp_query(db()); - int64_t key1 = FillImageTable(temp_query, 1, test_image).LastInsertId(); + int64_t key1 = FillImageTable(temp_query, + /*image_type=*/1, + test_image, + /*is_template=*/true).LastInsertId(); int64_t key2 = FillGlobalPropertiesTable( temp_query, "vrHelp", "menuTitle", 1, 1, 2, "auto", key1) .LastInsertId(); @@ -2051,7 +2146,8 @@ TEST_F(ResumptionSqlQueriesTest, kDeleteGlobalProperties_ExpectDataDeleted) { TEST_F(ResumptionSqlQueriesTest, kSelectCountImage_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - FillImageTable(temp_query, 2, "tst_image"); + FillImageTable( + temp_query, /*image_type=*/2, "tst_image", /*is_template=*/true); ValToPosPair p1(0, "tst_image"); ValToPosPair p2(1, ""); // Check @@ -2061,7 +2157,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCountImage_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kSelectPrimaryKeyImage_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t image_key = FillImageTable(temp_query, 2, "tst_image").LastInsertId(); + int64_t image_key = FillImageTable(temp_query, + /*image_type=*/2, + "tst_image", + /*is_template=*/true).LastInsertId(); ValToPosPair p1(0, "tst_image"); ValToPosPair p2(1, ""); // Check @@ -2071,7 +2170,8 @@ TEST_F(ResumptionSqlQueriesTest, kSelectPrimaryKeyImage_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kInsertImage_ExpectDataInserted) { // Arrange SQLQuery temp_query(db()); - FillImageTable(temp_query, 2, "tst_image"); + FillImageTable( + temp_query, /*image_type=*/2, "tst_image", /*is_template=*/true); const std::string select_count_image = "SELECT COUNT(*) FROM image;"; // Check CheckSelectQuery(select_count_image, 1, 0); @@ -2616,7 +2716,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCommandsFromCommand_ExpectDataCorrect) { app_id1, device_id, 9).LastInsertId(); - int64_t image_key = FillImageTable(temp_query, 2, "tst_image").LastInsertId(); + int64_t image_key = FillImageTable(temp_query, + /*image_type=*/2, + "tst_image", + /*is_template=*/true).LastInsertId(); FillChoiceTable( temp_query, 1, "menu_name", "sec_text", "tert_text", image_key) @@ -2656,7 +2759,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectCommandsFromChoice_ExpectDataCorrect) { app_id1, device_id, 9).LastInsertId(); - int64_t image_key = FillImageTable(temp_query, 2, "tst_image").LastInsertId(); + int64_t image_key = FillImageTable(temp_query, + /*image_type=*/2, + "tst_image", + /*is_template=*/true).LastInsertId(); int64_t choice_key = FillChoiceTable( @@ -2776,7 +2882,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectChoiceSets_ExpectDataCorrect) { app_id1, device_id, 9).LastInsertId(); - int64_t image_key = FillImageTable(temp_query, 2, "tst_image").LastInsertId(); + int64_t image_key = FillImageTable(temp_query, + /*image_type=*/2, + "tst_image", + /*is_template=*/true).LastInsertId(); int64_t choice_key = FillChoiceTable( temp_query, 1, "menu_name", "sec_text", "tert_text", image_key) @@ -2808,7 +2917,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectChoiceSets_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kSelectImage_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t image_key = FillImageTable(temp_query, 2, "tst_image").LastInsertId(); + int64_t image_key = FillImageTable(temp_query, + /*image_type=*/2, + "tst_image", + /*is_template=*/true).LastInsertId(); // Check ValToPosPair p1(0, IntToString(image_key)); ValToPosPair p2(1, ""); @@ -2846,7 +2958,10 @@ TEST_F(ResumptionSqlQueriesTest, TEST_F(ResumptionSqlQueriesTest, kSelectGlobalProperties_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t image_key = FillImageTable(temp_query, 2, "tst_image").LastInsertId(); + int64_t image_key = FillImageTable(temp_query, + /*image_type=*/2, + test_image, + /*is_template=*/true).LastInsertId(); int64_t glob_prop_key = FillGlobalPropertiesTable( temp_query, "tst_vr_title", "tst_menu", 2, 3, 3, "auto", image_key) @@ -2883,7 +2998,10 @@ TEST_F(ResumptionSqlQueriesTest, kSelectGlobalProperties_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kChecksVrHelpItem_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t image_key = FillImageTable(temp_query, 2, "tst_image").LastInsertId(); + int64_t image_key = FillImageTable(temp_query, + /*image_type=*/2, + "tst_image", + /*is_template=*/true).LastInsertId(); int64_t glob_prop_key = FillGlobalPropertiesTable( temp_query, "tst_vr_title", "tst_menu", 2, 3, 3, "auto", image_key) @@ -2900,7 +3018,10 @@ TEST_F(ResumptionSqlQueriesTest, kChecksVrHelpItem_ExpectDataCorrect) { TEST_F(ResumptionSqlQueriesTest, kSelectVrHelpItem_ExpectDataCorrect) { // Arrange SQLQuery temp_query(db()); - int64_t image_key = FillImageTable(temp_query, 2, "tst_image").LastInsertId(); + int64_t image_key = FillImageTable(temp_query, + /*image_type=*/2, + "tst_image", + /*is_template=*/true).LastInsertId(); int64_t glob_prop_key = FillGlobalPropertiesTable( temp_query, "tst_vr_title", "tst_menu", 2, 3, 3, "auto", image_key) diff --git a/src/components/application_manager/test/sdl_preloaded_pt.json b/src/components/application_manager/test/sdl_preloaded_pt.json index c5386f612e..ced0a9d603 100644 --- a/src/components/application_manager/test/sdl_preloaded_pt.json +++ b/src/components/application_manager/test/sdl_preloaded_pt.json @@ -20,6 +20,7 @@ "notifications_per_minute_by_priority": { "EMERGENCY": 60, "NAVIGATION": 15, + "PROJECTION": 15, "COMMUNICATION": 6, "NORMAL": 4, "NONE": 0 diff --git a/src/components/application_manager/test/sdl_pt_update.json b/src/components/application_manager/test/sdl_pt_update.json index e013243760..f87ae40eac 100644 --- a/src/components/application_manager/test/sdl_pt_update.json +++ b/src/components/application_manager/test/sdl_pt_update.json @@ -1716,6 +1716,7 @@ "COMMUNICATION" : 6, "EMERGENCY" : 60, "NAVIGATION" : 15, + "PROJECTION": 15, "NONE" : 0, "NORMAL" : 4, "VOICECOMM" : 10 diff --git a/src/components/application_manager/test/state_controller/state_controller_test.cc b/src/components/application_manager/test/state_controller/state_controller_test.cc index fe4d1d2ee8..8a49a2527f 100644 --- a/src/components/application_manager/test/state_controller/state_controller_test.cc +++ b/src/components/application_manager/test/state_controller/state_controller_test.cc @@ -81,24 +81,29 @@ const uint32_t kHMIAppID = 2718u; struct HmiStatesComparator { mobile_apis::HMILevel::eType hmi_level_; mobile_apis::AudioStreamingState::eType audio_streaming_state_; + mobile_apis::VideoStreamingState::eType video_streaming_state_; mobile_apis::SystemContext::eType system_context_; HmiStatesComparator( mobile_apis::HMILevel::eType hmi_level, mobile_apis::AudioStreamingState::eType audio_streaming_state, + mobile_apis::VideoStreamingState::eType video_streaming_state, mobile_apis::SystemContext::eType system_context) : hmi_level_(hmi_level) , audio_streaming_state_(audio_streaming_state) + , video_streaming_state_(video_streaming_state) , system_context_(system_context) {} HmiStatesComparator(am::HmiStatePtr state_ptr) : hmi_level_(state_ptr->hmi_level()) , audio_streaming_state_(state_ptr->audio_streaming_state()) + , video_streaming_state_(state_ptr->video_streaming_state()) , system_context_(state_ptr->system_context()) {} bool operator()(am::HmiStatePtr state_ptr) const { return state_ptr->hmi_level() == hmi_level_ && state_ptr->audio_streaming_state() == audio_streaming_state_ && + state_ptr->video_streaming_state() == video_streaming_state_ && state_ptr->system_context() == system_context_; } }; @@ -206,7 +211,8 @@ class StateControllerImplTest : public ::testing::Test { am::HmiStatePtr createHmiState( mobile_apis::HMILevel::eType hmi_level, - mobile_apis::AudioStreamingState::eType aidio_ss, + mobile_apis::AudioStreamingState::eType audio_ss, + mobile_apis::VideoStreamingState::eType video_ss, mobile_apis::SystemContext::eType system_context) { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; @@ -215,7 +221,8 @@ class StateControllerImplTest : public ::testing::Test { am::HmiStatePtr state = utils::MakeShared<am::HmiState>(simple_app_, app_manager_mock_); state->set_hmi_level(hmi_level); - state->set_audio_streaming_state(aidio_ss); + state->set_audio_streaming_state(audio_ss); + state->set_video_streaming_state(video_ss); state->set_system_context(system_context); return state; } @@ -228,6 +235,7 @@ class StateControllerImplTest : public ::testing::Test { am::HmiStatePtr CreateHmiStateByHmiStateType( const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_ss, + const mobile_apis::VideoStreamingState::eType video_ss, const mobile_apis::SystemContext::eType system_context, const am::ApplicationSharedPtr app) { am::HmiStatePtr new_state = @@ -235,6 +243,7 @@ class StateControllerImplTest : public ::testing::Test { new_state->set_hmi_level(hmi_level); new_state->set_audio_streaming_state(audio_ss); + new_state->set_video_streaming_state(video_ss); new_state->set_system_context(system_context); return new_state; @@ -248,27 +257,38 @@ class StateControllerImplTest : public ::testing::Test { std::vector<am::HmiStatePtr>& result_hmi_state) { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; + namespace VideoStreamingState = mobile_apis::VideoStreamingState; namespace SystemContext = mobile_apis::SystemContext; - result_hmi_state.push_back(createHmiState(HMILevel::HMI_NONE, - AudioStreamingState::NOT_AUDIBLE, - SystemContext::SYSCTXT_MAIN)); result_hmi_state.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, + SystemContext::SYSCTXT_MAIN)); + result_hmi_state.push_back( + createHmiState(HMILevel::HMI_NONE, + AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_VRSESSION)); - result_hmi_state.push_back(createHmiState(HMILevel::HMI_NONE, - AudioStreamingState::NOT_AUDIBLE, - SystemContext::SYSCTXT_MENU)); result_hmi_state.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, + SystemContext::SYSCTXT_MENU)); + result_hmi_state.push_back( + createHmiState(HMILevel::HMI_NONE, + AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_HMI_OBSCURED)); - result_hmi_state.push_back(createHmiState(HMILevel::HMI_NONE, - AudioStreamingState::NOT_AUDIBLE, - SystemContext::SYSCTXT_ALERT)); - result_hmi_state.push_back(createHmiState(HMILevel::HMI_BACKGROUND, - AudioStreamingState::NOT_AUDIBLE, - SystemContext::SYSCTXT_MAIN)); + result_hmi_state.push_back( + createHmiState(HMILevel::HMI_NONE, + AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, + SystemContext::SYSCTXT_ALERT)); + result_hmi_state.push_back( + createHmiState(HMILevel::HMI_BACKGROUND, + AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, + SystemContext::SYSCTXT_MAIN)); } /** @@ -280,20 +300,29 @@ class StateControllerImplTest : public ::testing::Test { std::vector<am::HmiStatePtr>& result_hmi_state) { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; + namespace VideoStreamingState = mobile_apis::VideoStreamingState; namespace SystemContext = mobile_apis::SystemContext; PrepareCommonStateResults(result_hmi_state); - result_hmi_state.push_back(createHmiState(HMILevel::HMI_LIMITED, - AudioStreamingState::ATTENUATED, - SystemContext::SYSCTXT_MAIN)); - result_hmi_state.push_back(createHmiState(HMILevel::HMI_LIMITED, - AudioStreamingState::ATTENUATED, - SystemContext::SYSCTXT_MAIN)); - result_hmi_state.push_back(createHmiState(HMILevel::HMI_FULL, - AudioStreamingState::NOT_AUDIBLE, - SystemContext::SYSCTXT_MAIN)); - result_hmi_state.push_back(createHmiState(HMILevel::HMI_FULL, - AudioStreamingState::ATTENUATED, - SystemContext::SYSCTXT_MAIN)); + result_hmi_state.push_back( + createHmiState(HMILevel::HMI_LIMITED, + AudioStreamingState::ATTENUATED, + VideoStreamingState::NOT_STREAMABLE, + SystemContext::SYSCTXT_MAIN)); + result_hmi_state.push_back( + createHmiState(HMILevel::HMI_LIMITED, + AudioStreamingState::ATTENUATED, + VideoStreamingState::NOT_STREAMABLE, + SystemContext::SYSCTXT_MAIN)); + result_hmi_state.push_back( + createHmiState(HMILevel::HMI_FULL, + AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, + SystemContext::SYSCTXT_MAIN)); + result_hmi_state.push_back( + createHmiState(HMILevel::HMI_FULL, + AudioStreamingState::ATTENUATED, + VideoStreamingState::NOT_STREAMABLE, + SystemContext::SYSCTXT_MAIN)); } /** @@ -305,6 +334,7 @@ class StateControllerImplTest : public ::testing::Test { std::vector<am::HmiStatePtr>& result_hmi_state, ApplicationType app_t) { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; + namespace VideoStreamingState = mobile_apis::VideoStreamingState; namespace SystemContext = mobile_apis::SystemContext; switch (app_t) { @@ -313,6 +343,7 @@ class StateControllerImplTest : public ::testing::Test { result_hmi_state.push_back( createHmiState(HMILevel::HMI_FULL, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); break; } @@ -321,18 +352,22 @@ class StateControllerImplTest : public ::testing::Test { result_hmi_state.push_back( createHmiState(HMILevel::HMI_BACKGROUND, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); result_hmi_state.push_back( createHmiState(HMILevel::HMI_BACKGROUND, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); result_hmi_state.push_back( createHmiState(HMILevel::HMI_BACKGROUND, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); result_hmi_state.push_back( createHmiState(HMILevel::HMI_BACKGROUND, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); break; } @@ -341,18 +376,22 @@ class StateControllerImplTest : public ::testing::Test { result_hmi_state.push_back( createHmiState(HMILevel::HMI_LIMITED, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); result_hmi_state.push_back( createHmiState(HMILevel::HMI_LIMITED, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); result_hmi_state.push_back( createHmiState(HMILevel::HMI_LIMITED, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); result_hmi_state.push_back( createHmiState(HMILevel::HMI_LIMITED, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); break; } @@ -369,6 +408,7 @@ class StateControllerImplTest : public ::testing::Test { std::vector<am::HmiStatePtr>& result_hmi_state, ApplicationType app_t) { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; + namespace VideoStreamingState = mobile_apis::VideoStreamingState; namespace SystemContext = mobile_apis::SystemContext; switch (app_t) { case APP_TYPE_NON_MEDIA: { @@ -376,6 +416,7 @@ class StateControllerImplTest : public ::testing::Test { result_hmi_state.push_back( createHmiState(HMILevel::HMI_FULL, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); break; } @@ -385,18 +426,22 @@ class StateControllerImplTest : public ::testing::Test { result_hmi_state.push_back( createHmiState(HMILevel::HMI_LIMITED, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); result_hmi_state.push_back( createHmiState(HMILevel::HMI_LIMITED, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); result_hmi_state.push_back( createHmiState(HMILevel::HMI_FULL, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); result_hmi_state.push_back( createHmiState(HMILevel::HMI_FULL, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); break; } @@ -417,6 +462,7 @@ class StateControllerImplTest : public ::testing::Test { std::vector<am::HmiStatePtr>& result_hmi_state, ApplicationType app_t) { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; + namespace VideoStreamingState = mobile_apis::VideoStreamingState; namespace SystemContext = mobile_apis::SystemContext; switch (app_t) { case APP_TYPE_NON_MEDIA: { @@ -424,6 +470,7 @@ class StateControllerImplTest : public ::testing::Test { result_hmi_state.push_back( createHmiState(HMILevel::HMI_FULL, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); break; } @@ -432,18 +479,22 @@ class StateControllerImplTest : public ::testing::Test { result_hmi_state.push_back( createHmiState(HMILevel::HMI_LIMITED, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); result_hmi_state.push_back( createHmiState(HMILevel::HMI_LIMITED, AudioStreamingState::ATTENUATED, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); result_hmi_state.push_back( createHmiState(HMILevel::HMI_FULL, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); result_hmi_state.push_back( createHmiState(HMILevel::HMI_FULL, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); break; } @@ -465,6 +516,7 @@ class StateControllerImplTest : public ::testing::Test { std::vector<am::HmiStatePtr>& result_hmi_state, ApplicationType app_t) { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; + namespace VideoStreamingState = mobile_apis::VideoStreamingState; namespace SystemContext = mobile_apis::SystemContext; switch (app_t) { case APP_TYPE_NON_MEDIA: { @@ -472,6 +524,7 @@ class StateControllerImplTest : public ::testing::Test { result_hmi_state.push_back( createHmiState(HMILevel::HMI_FULL, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); break; } @@ -630,146 +683,180 @@ class StateControllerImplTest : public ::testing::Test { void FillStatesLists() { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; + namespace VideoStreamingState = mobile_apis::VideoStreamingState; namespace SystemContext = mobile_apis::SystemContext; // Valid states for not audio app valid_states_for_not_audio_app_.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); valid_states_for_not_audio_app_.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_VRSESSION)); valid_states_for_not_audio_app_.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MENU)); valid_states_for_not_audio_app_.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_HMI_OBSCURED)); valid_states_for_not_audio_app_.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_ALERT)); valid_states_for_not_audio_app_.push_back( createHmiState(HMILevel::HMI_BACKGROUND, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); valid_states_for_not_audio_app_.push_back( createHmiState(HMILevel::HMI_FULL, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); // Valid states audio app valid_states_for_audio_app_.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); valid_states_for_audio_app_.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_VRSESSION)); valid_states_for_audio_app_.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MENU)); valid_states_for_audio_app_.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_HMI_OBSCURED)); valid_states_for_audio_app_.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_ALERT)); valid_states_for_audio_app_.push_back( createHmiState(HMILevel::HMI_BACKGROUND, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); valid_states_for_audio_app_.push_back( createHmiState(HMILevel::HMI_LIMITED, AudioStreamingState::AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); valid_states_for_audio_app_.push_back( createHmiState(HMILevel::HMI_LIMITED, AudioStreamingState::ATTENUATED, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); valid_states_for_audio_app_.push_back( createHmiState(HMILevel::HMI_FULL, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); valid_states_for_audio_app_.push_back( createHmiState(HMILevel::HMI_FULL, AudioStreamingState::AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); // Common Invalid States common_invalid_states_.push_back( createHmiState(HMILevel::INVALID_ENUM, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); common_invalid_states_.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::INVALID_ENUM, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); common_invalid_states_.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::INVALID_ENUM)); common_invalid_states_.push_back( createHmiState(HMILevel::INVALID_ENUM, AudioStreamingState::INVALID_ENUM, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); common_invalid_states_.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::INVALID_ENUM, + VideoStreamingState::NOT_STREAMABLE, SystemContext::INVALID_ENUM)); common_invalid_states_.push_back( createHmiState(HMILevel::INVALID_ENUM, AudioStreamingState::INVALID_ENUM, + VideoStreamingState::NOT_STREAMABLE, SystemContext::INVALID_ENUM)); // Invalid States for audio apps invalid_states_for_audio_app.push_back( createHmiState(HMILevel::HMI_LIMITED, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); invalid_states_for_audio_app.push_back( createHmiState(HMILevel::HMI_BACKGROUND, AudioStreamingState::AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); invalid_states_for_audio_app.push_back( createHmiState(HMILevel::HMI_BACKGROUND, AudioStreamingState::ATTENUATED, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); invalid_states_for_audio_app.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); invalid_states_for_audio_app.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::ATTENUATED, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); invalid_states_for_audio_app.push_back( createHmiState(HMILevel::HMI_NONE, AudioStreamingState::ATTENUATED, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); // Invalid States for not audio apps invalid_states_for_not_audio_app.push_back( createHmiState(HMILevel::HMI_LIMITED, AudioStreamingState::ATTENUATED, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); invalid_states_for_not_audio_app.push_back( createHmiState(HMILevel::HMI_LIMITED, AudioStreamingState::AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); invalid_states_for_not_audio_app.push_back( createHmiState(HMILevel::HMI_FULL, AudioStreamingState::ATTENUATED, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); invalid_states_for_not_audio_app.push_back( createHmiState(HMILevel::HMI_FULL, AudioStreamingState::AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN)); // Valid state ids @@ -939,7 +1026,7 @@ class StateControllerImplTest : public ::testing::Test { am::ApplicationSharedPtr app, NiceMock<application_manager_test::MockApplication>* app_mock, am::HmiStatePtr state) { - EXPECT_CALL(*app_mock, RegularHmiState()).WillOnce(Return(state)); + ON_CALL(*app_mock, RegularHmiState()).WillByDefault(Return(state)); EXPECT_CALL(app_manager_mock_, SendHMIStatusNotification(app)).Times(0); EXPECT_CALL(app_manager_mock_, OnHMILevelChanged(app->app_id(), _, _)) .Times(0); @@ -954,46 +1041,52 @@ class StateControllerImplTest : public ::testing::Test { am::HmiStatePtr NoneNotAudibleState() { return createHmiState(mobile_apis::HMILevel::HMI_NONE, mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, mobile_apis::SystemContext::SYSCTXT_MAIN); } am::HmiStatePtr FullAudibleState() { return createHmiState(mobile_apis::HMILevel::HMI_FULL, mobile_apis::AudioStreamingState::AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, mobile_apis::SystemContext::SYSCTXT_MAIN); } am::HmiStatePtr FullNotAudibleState() { return createHmiState(mobile_apis::HMILevel::HMI_FULL, mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, mobile_apis::SystemContext::SYSCTXT_MAIN); } am::HmiStatePtr LimitedState() { return createHmiState(mobile_apis::HMILevel::HMI_LIMITED, mobile_apis::AudioStreamingState::AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, mobile_apis::SystemContext::SYSCTXT_MAIN); } am::HmiStatePtr BackgroundState() { return createHmiState(mobile_apis::HMILevel::HMI_BACKGROUND, mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, mobile_apis::SystemContext::SYSCTXT_MAIN); } void ApplyTempStatesForApplication( - NiceMock<application_manager_test::MockApplication>& application, + am::ApplicationSharedPtr app, + NiceMock<application_manager_test::MockApplication>& app_mock, std::vector<am::HmiState::StateID>& state_ids) { using smart_objects::SmartObject; using am::event_engine::Event; namespace FunctionID = hmi_apis::FunctionID; - EXPECT_CALL(application, CurrentHmiState()) + EXPECT_CALL(app_mock, CurrentHmiState()) .WillRepeatedly(Return(NoneNotAudibleState())); for (size_t i = 0; i < state_ids.size(); ++i) { am::HmiState::StateID state_id = state_ids[i]; - EXPECT_CALL(application, + EXPECT_CALL(app_mock, AddHMIState(Truly(HmiStatesIDComparator(state_id)))); switch (state_id) { case am::HmiState::StateID::STATE_ID_VR_SESSION: { @@ -1029,30 +1122,31 @@ class StateControllerImplTest : public ::testing::Test { break; } case am::HmiState::StateID::STATE_ID_NAVI_STREAMING: { - state_ctrl_->OnNaviStreamingStarted(); + state_ctrl_->OnVideoStreamingStarted(app); break; } default: break; } - EXPECT_CALL(application, AddHMIState(_)).Times(0); + EXPECT_CALL(app_mock, AddHMIState(_)).Times(0); } } void CheckStateApplyingForApplication( - NiceMock<application_manager_test::MockApplication>& application, + am::ApplicationSharedPtr app, + NiceMock<application_manager_test::MockApplication>& app_mock, std::vector<am::HmiState::StateID>& state_ids) { using smart_objects::SmartObject; using am::event_engine::Event; namespace FunctionID = hmi_apis::FunctionID; - EXPECT_CALL(application, CurrentHmiState()) + EXPECT_CALL(app_mock, CurrentHmiState()) .WillRepeatedly(Return(NoneNotAudibleState())); for (uint32_t i = 0; i < state_ids.size(); ++i) { am::HmiState::StateID state_id = state_ids[i]; - EXPECT_CALL(application, - AddHMIState(Truly(HmiStatesIDComparator(state_id)))).Times(1); + EXPECT_CALL(app_mock, AddHMIState(Truly(HmiStatesIDComparator(state_id)))) + .Times(1); switch (state_id) { case am::HmiState::StateID::STATE_ID_VR_SESSION: { @@ -1088,23 +1182,23 @@ class StateControllerImplTest : public ::testing::Test { break; } case am::HmiState::StateID::STATE_ID_NAVI_STREAMING: { - state_ctrl_->OnNaviStreamingStarted(); + state_ctrl_->OnVideoStreamingStarted(app); break; } default: break; } - EXPECT_CALL(application, AddHMIState(_)).Times(0); + EXPECT_CALL(app_mock, AddHMIState(_)).Times(0); } for (uint32_t i = 0; i < state_ids.size(); ++i) { am::HmiState::StateID state_id = state_ids[i]; - EXPECT_CALL(application, RemoveHMIState(state_id)).Times(1); + EXPECT_CALL(app_mock, RemoveHMIState(state_id)).Times(1); - EXPECT_CALL(application, PostponedHmiState()) + EXPECT_CALL(app_mock, PostponedHmiState()) .WillOnce(Return(NoneNotAudibleState())); - EXPECT_CALL(application, RemovePostponedState()); + EXPECT_CALL(app_mock, RemovePostponedState()); switch (state_id) { case am::HmiState::StateID::STATE_ID_VR_SESSION: { @@ -1140,14 +1234,14 @@ class StateControllerImplTest : public ::testing::Test { break; } case am::HmiState::StateID::STATE_ID_NAVI_STREAMING: { - state_ctrl_->OnNaviStreamingStopped(); + state_ctrl_->OnVideoStreamingStopped(app); break; } default: break; } - EXPECT_CALL(application, RemoveHMIState(_)).Times(0); + EXPECT_CALL(app_mock, RemoveHMIState(_)).Times(0); } } }; @@ -1199,10 +1293,13 @@ TEST_F(StateControllerImplTest, OnStateChangedToNone) { HmiStatePtr none_state = createHmiState(HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN); - HmiStatePtr not_none_state = createHmiState(HMILevel::HMI_FULL, - AudioStreamingState::NOT_AUDIBLE, - SystemContext::SYSCTXT_MAIN); + HmiStatePtr not_none_state = + createHmiState(HMILevel::HMI_FULL, + AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, + SystemContext::SYSCTXT_MAIN); EXPECT_CALL(*simple_app_ptr_, ResetDataInNone()).Times(0); state_ctrl_->OnStateChanged(simple_app_, none_state, not_none_state); @@ -1214,9 +1311,11 @@ TEST_F(StateControllerImplTest, OnStateChangedToNone) { TEST_F(StateControllerImplTest, MoveSimpleAppToValidStates) { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; + namespace VideoStreamingState = mobile_apis::VideoStreamingState; namespace SystemContext = mobile_apis::SystemContext; HmiStatePtr initial_state = createHmiState(HMILevel::INVALID_ENUM, AudioStreamingState::INVALID_ENUM, + VideoStreamingState::INVALID_ENUM, SystemContext::INVALID_ENUM); for (std::vector<HmiStatePtr>::iterator it = @@ -1243,6 +1342,7 @@ TEST_F(StateControllerImplTest, MoveSimpleAppToValidStates) { TEST_F(StateControllerImplTest, MoveAudioNotResumeAppToValidStates) { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; + namespace VideoStreamingState = mobile_apis::VideoStreamingState; namespace SystemContext = mobile_apis::SystemContext; am::ApplicationSharedPtr audio_app = media_navi_vc_app_; @@ -1251,6 +1351,7 @@ TEST_F(StateControllerImplTest, MoveAudioNotResumeAppToValidStates) { HmiStatePtr initial_state = createHmiState(HMILevel::INVALID_ENUM, AudioStreamingState::INVALID_ENUM, + VideoStreamingState::INVALID_ENUM, SystemContext::INVALID_ENUM); for (std::vector<HmiStatePtr>::iterator it = @@ -1277,6 +1378,7 @@ TEST_F(StateControllerImplTest, MoveAudioNotResumeAppToValidStates) { TEST_F(StateControllerImplTest, MoveAudioResumeAppToValidStates) { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; + namespace VideoStreamingState = mobile_apis::VideoStreamingState; namespace SystemContext = mobile_apis::SystemContext; am::ApplicationSharedPtr audio_app = media_navi_vc_app_; @@ -1285,6 +1387,7 @@ TEST_F(StateControllerImplTest, MoveAudioResumeAppToValidStates) { HmiStatePtr initial_state = createHmiState(HMILevel::INVALID_ENUM, AudioStreamingState::INVALID_ENUM, + VideoStreamingState::INVALID_ENUM, SystemContext::INVALID_ENUM); // Set all valid states for audio app @@ -1360,7 +1463,6 @@ TEST_F(StateControllerImplTest, MoveAppFromValidStateToInvalid) { TEST_F(StateControllerImplTest, SetFullToSimpleAppWhileAnotherSimpleAppIsInFull) { namespace HMILevel = mobile_apis::HMILevel; - namespace AudioStreamingState = mobile_apis::AudioStreamingState; namespace SystemContext = mobile_apis::SystemContext; am::ApplicationSharedPtr app_in_full; NiceMock<application_manager_test::MockApplication>* app_in_full_mock; @@ -1389,7 +1491,6 @@ TEST_F(StateControllerImplTest, TEST_F(StateControllerImplTest, SetFullToSimpleAppWhileAudioAppAppIsInFull) { namespace HMILevel = mobile_apis::HMILevel; - namespace AudioStreamingState = mobile_apis::AudioStreamingState; namespace SystemContext = mobile_apis::SystemContext; am::ApplicationSharedPtr app_in_full = media_navi_vc_app_; NiceMock<application_manager_test::MockApplication>* app_in_full_mock = @@ -1415,7 +1516,6 @@ TEST_F(StateControllerImplTest, SetFullToSimpleAppWhileAudioAppAppIsInFull) { TEST_F(StateControllerImplTest, SetFullToAudioAppAppWhileAnotherTypeAudioAppAppIsInFull) { namespace HMILevel = mobile_apis::HMILevel; - namespace AudioStreamingState = mobile_apis::AudioStreamingState; namespace SystemContext = mobile_apis::SystemContext; am::ApplicationSharedPtr app_in_full = media_app_; @@ -1442,7 +1542,6 @@ TEST_F(StateControllerImplTest, TEST_F(StateControllerImplTest, SetFullToAudioAppAppWhileSameTypeAudioAppAppIsInFull) { namespace HMILevel = mobile_apis::HMILevel; - namespace AudioStreamingState = mobile_apis::AudioStreamingState; namespace SystemContext = mobile_apis::SystemContext; NiceMock<application_manager_test::MockApplication>* app_in_full_mock; am::ApplicationSharedPtr app_in_full = @@ -1468,7 +1567,6 @@ TEST_F(StateControllerImplTest, TEST_F(StateControllerImplTest, SetFullToAudioAppAppWhileSameTypeAudioAppAppIsInLimited) { namespace HMILevel = mobile_apis::HMILevel; - namespace AudioStreamingState = mobile_apis::AudioStreamingState; namespace SystemContext = mobile_apis::SystemContext; NiceMock<application_manager_test::MockApplication>* app_in_limited_mock; @@ -1495,7 +1593,6 @@ TEST_F(StateControllerImplTest, TEST_F(StateControllerImplTest, SetLimitedToAudioAppAppWhileSameTypeAudioAppAppIsInLimited) { namespace HMILevel = mobile_apis::HMILevel; - namespace AudioStreamingState = mobile_apis::AudioStreamingState; namespace SystemContext = mobile_apis::SystemContext; NiceMock<application_manager_test::MockApplication>* app_in_limited_mock; am::ApplicationSharedPtr app_in_limited = @@ -1523,7 +1620,6 @@ TEST_F(StateControllerImplTest, TEST_F(StateControllerImplTest, SetLimitedToAudioAppAppWhileOtherTypeAudioAppAppIsInLimited) { namespace HMILevel = mobile_apis::HMILevel; - namespace AudioStreamingState = mobile_apis::AudioStreamingState; namespace SystemContext = mobile_apis::SystemContext; am::ApplicationSharedPtr app_in_limited = navi_app_; @@ -1542,11 +1638,12 @@ TEST_F(StateControllerImplTest, LimitedState()); ExpectAppWontChangeHmiStateDueToConflictResolving( app_in_limited, app_in_limited_mock, LimitedState()); + state_ctrl_->SetRegularState(app_moved_to_limited, LimitedState(), false); } TEST_F(StateControllerImplTest, - SetLimitedToAudioAppAppWhileOtherTypeAudioAppAppIsInFull) { + DISABLED_SetLimitedToAudioAppAppWhileOtherTypeAudioAppAppIsInFull) { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; namespace SystemContext = mobile_apis::SystemContext; @@ -1765,8 +1862,10 @@ TEST_F(StateControllerImplTest, media_navi_vc_app_ptr_, BackgroundState(), FullAudibleState()); - ExpectAppChangeHmiStateDueToConflictResolving( - media_app_, media_app_ptr_, LimitedState(), BackgroundState()); + + EXPECT_CALL(*media_app_ptr_, RegularHmiState()) + .WillOnce(Return(LimitedState())); + ExpectAppChangeHmiStateDueToConflictResolving( navi_app_, navi_app_ptr_, LimitedState(), BackgroundState()); ExpectAppChangeHmiStateDueToConflictResolving( @@ -1788,8 +1887,10 @@ TEST_F(StateControllerImplTest, media_navi_vc_app_ptr_, BackgroundState(), FullAudibleState()); - ExpectAppChangeHmiStateDueToConflictResolving( - media_app_, media_app_ptr_, LimitedState(), BackgroundState()); + + EXPECT_CALL(*media_app_ptr_, RegularHmiState()) + .WillOnce(Return(LimitedState())); + ExpectAppChangeHmiStateDueToConflictResolving( navi_app_, navi_app_ptr_, LimitedState(), BackgroundState()); ExpectAppChangeHmiStateDueToConflictResolving( @@ -1817,6 +1918,7 @@ TEST_F(StateControllerImplTest, DISABLED_ActivateAppSuccessReceivedFromHMI) { hmi_states.push_back( StateLevelPair(createHmiState(HMILevel::HMI_NONE, AudioStreamingState::NOT_AUDIBLE, + VideoStreamingState::NOT_STREAMABLE, SystemContext::SYSCTXT_MAIN), Common_HMILevel::NONE)); std::vector<StateLevelPair> initial_hmi_states = hmi_states; @@ -1940,44 +2042,50 @@ TEST_F(StateControllerImplTest, ActivateAppInvalidCorrelationId) { state_ctrl_->on_event(event); } -TEST_F(StateControllerImplTest, ApplyTempStatesForSimpleApp) { +TEST_F(StateControllerImplTest, DISABLED_ApplyTempStatesForSimpleApp) { InsertApplication(simple_app_); - CheckStateApplyingForApplication(*simple_app_ptr_, valid_state_ids_); + CheckStateApplyingForApplication( + simple_app_, *simple_app_ptr_, valid_state_ids_); } -TEST_F(StateControllerImplTest, ApplyTempStatesForMediaApp) { +TEST_F(StateControllerImplTest, DISABLED_ApplyTempStatesForMediaApp) { InsertApplication(media_app_); - CheckStateApplyingForApplication(*media_app_ptr_, valid_state_ids_); + CheckStateApplyingForApplication( + media_app_, *media_app_ptr_, valid_state_ids_); } TEST_F(StateControllerImplTest, ApplyTempStatesForNaviApp) { InsertApplication(navi_app_); - CheckStateApplyingForApplication(*navi_app_ptr_, valid_state_ids_); + CheckStateApplyingForApplication(navi_app_, *navi_app_ptr_, valid_state_ids_); } -TEST_F(StateControllerImplTest, ApplyTempStatesForVCApp) { +TEST_F(StateControllerImplTest, DISABLED_ApplyTempStatesForVCApp) { InsertApplication(vc_app_); - CheckStateApplyingForApplication(*vc_app_ptr_, valid_state_ids_); + CheckStateApplyingForApplication(vc_app_, *vc_app_ptr_, valid_state_ids_); } TEST_F(StateControllerImplTest, ApplyTempStatesForMediaNaviApp) { InsertApplication(media_navi_app_); - CheckStateApplyingForApplication(*media_navi_app_ptr_, valid_state_ids_); + CheckStateApplyingForApplication( + media_navi_app_, *media_navi_app_ptr_, valid_state_ids_); } -TEST_F(StateControllerImplTest, ApplyTempStatesForMediaVCApp) { +TEST_F(StateControllerImplTest, DISABLED_ApplyTempStatesForMediaVCApp) { InsertApplication(media_vc_app_); - CheckStateApplyingForApplication(*media_vc_app_ptr_, valid_state_ids_); + CheckStateApplyingForApplication( + media_vc_app_, *media_vc_app_ptr_, valid_state_ids_); } TEST_F(StateControllerImplTest, ApplyTempStatesForNaviVCApp) { InsertApplication(navi_vc_app_); - CheckStateApplyingForApplication(*navi_vc_app_ptr_, valid_state_ids_); + CheckStateApplyingForApplication( + navi_vc_app_, *navi_vc_app_ptr_, valid_state_ids_); } TEST_F(StateControllerImplTest, ApplyTempStatesForMediaNaviVCApp) { InsertApplication(media_navi_vc_app_); - CheckStateApplyingForApplication(*media_navi_vc_app_ptr_, valid_state_ids_); + CheckStateApplyingForApplication( + media_navi_vc_app_, *media_navi_vc_app_ptr_, valid_state_ids_); } TEST_F(StateControllerImplTest, SetStatePhoneCallForNonMediaApplication) { @@ -2108,8 +2216,8 @@ TEST_F(StateControllerImplTest, TEST_F(StateControllerImplTest, SetNaviStreamingStateForNonMediaApplication) { am::HmiStatePtr state_navi_streming = - utils::MakeShared<am::NaviStreamingHmiState>(simple_app_, - app_manager_mock_); + utils::MakeShared<am::VideoStreamingHmiState>(simple_app_, + app_manager_mock_); TestSetState(simple_app_, state_navi_streming, APP_TYPE_NON_MEDIA, @@ -2117,10 +2225,10 @@ TEST_F(StateControllerImplTest, SetNaviStreamingStateForNonMediaApplication) { } TEST_F(StateControllerImplTest, - SetNaviStreamingStateMediaApplicationAttenuatedNotSupported) { + DISABLED_SetNaviStreamingStateMediaApplicationAttenuatedNotSupported) { am::HmiStatePtr state_navi_streming = - utils::MakeShared<am::NaviStreamingHmiState>(media_app_, - app_manager_mock_); + utils::MakeShared<am::VideoStreamingHmiState>(media_app_, + app_manager_mock_); EXPECT_CALL(app_manager_mock_, is_attenuated_supported()) .WillRepeatedly(Return(false)); TestSetState(media_app_, @@ -2130,10 +2238,10 @@ TEST_F(StateControllerImplTest, } TEST_F(StateControllerImplTest, - SetNaviStreamingStateMediaApplicationAttenuatedSupported) { + DISABLED_SetNaviStreamingStateMediaApplicationAttenuatedSupported) { am::HmiStatePtr state_navi_streming = - utils::MakeShared<am::NaviStreamingHmiState>(media_app_, - app_manager_mock_); + utils::MakeShared<am::VideoStreamingHmiState>(media_app_, + app_manager_mock_); EXPECT_CALL(app_manager_mock_, is_attenuated_supported()) .WillRepeatedly(Return(true)); TestSetState(media_app_, @@ -2143,9 +2251,9 @@ TEST_F(StateControllerImplTest, } TEST_F(StateControllerImplTest, - SetNaviStreamingStateVCApplicationAttenuatedNotSupported) { + DISABLED_SetNaviStreamingStateVCApplicationAttenuatedNotSupported) { am::HmiStatePtr state_navi_streming = - utils::MakeShared<am::NaviStreamingHmiState>(vc_app_, app_manager_mock_); + utils::MakeShared<am::VideoStreamingHmiState>(vc_app_, app_manager_mock_); EXPECT_CALL(app_manager_mock_, is_attenuated_supported()) .WillRepeatedly(Return(false)); TestSetState(vc_app_, @@ -2155,9 +2263,9 @@ TEST_F(StateControllerImplTest, } TEST_F(StateControllerImplTest, - SetNaviStreamingStateVCApplicationAttenuatedSupported) { + DISABLED_SetNaviStreamingStateVCApplicationAttenuatedSupported) { am::HmiStatePtr state_navi_streming = - utils::MakeShared<am::NaviStreamingHmiState>(vc_app_, app_manager_mock_); + utils::MakeShared<am::VideoStreamingHmiState>(vc_app_, app_manager_mock_); EXPECT_CALL(app_manager_mock_, is_attenuated_supported()) .WillRepeatedly(Return(true)); TestSetState(vc_app_, @@ -2166,20 +2274,21 @@ TEST_F(StateControllerImplTest, &StateControllerImplTest::PrepareVRTTSHMIStateResults); } -TEST_F(StateControllerImplTest, SetNaviStreamingStateNaviApplication) { +TEST_F(StateControllerImplTest, DISABLED_SetNaviStreamingStateNaviApplication) { am::HmiStatePtr state_navi_streming = - utils::MakeShared<am::NaviStreamingHmiState>(navi_app_, - app_manager_mock_); + utils::MakeShared<am::VideoStreamingHmiState>(navi_app_, + app_manager_mock_); TestSetState(navi_app_, state_navi_streming, APP_TYPE_NAVI, &StateControllerImplTest::PrepareNaviStreamingHMIStateResults); } -TEST_F(StateControllerImplTest, SetNaviStreamingStateMediaNaviApplication) { +TEST_F(StateControllerImplTest, + DISABLED_SetNaviStreamingStateMediaNaviApplication) { am::HmiStatePtr state_navi_streming = - utils::MakeShared<am::NaviStreamingHmiState>(media_navi_app_, - app_manager_mock_); + utils::MakeShared<am::VideoStreamingHmiState>(media_navi_app_, + app_manager_mock_); TestSetState(media_navi_app_, state_navi_streming, APP_TYPE_NAVI, @@ -2240,7 +2349,7 @@ TEST_F(StateControllerImplTest, EXPECT_CALL(app_manager_mock_, is_attenuated_supported()) .WillRepeatedly(Return(false)); - TestMixState<am::PhoneCallHmiState, am::NaviStreamingHmiState>( + TestMixState<am::PhoneCallHmiState, am::VideoStreamingHmiState>( &StateControllerImplTest::PreparePhoneCallHMIStateResults); } @@ -2249,7 +2358,7 @@ TEST_F(StateControllerImplTest, EXPECT_CALL(app_manager_mock_, is_attenuated_supported()) .WillRepeatedly(Return(true)); - TestMixState<am::PhoneCallHmiState, am::NaviStreamingHmiState>( + TestMixState<am::PhoneCallHmiState, am::VideoStreamingHmiState>( &StateControllerImplTest::PreparePhoneCallHMIStateResults); } @@ -2278,7 +2387,7 @@ TEST_F(StateControllerImplTest, MixNaviStreamingWithVRAttenuatedNotSupported) { EXPECT_CALL(app_manager_mock_, is_attenuated_supported()) .WillRepeatedly(Return(false)); - TestMixState<am::VRHmiState, am::NaviStreamingHmiState>( + TestMixState<am::VRHmiState, am::VideoStreamingHmiState>( &StateControllerImplTest::PrepareVRTTSHMIStateResults); } @@ -2286,7 +2395,7 @@ TEST_F(StateControllerImplTest, MixNaviStreamingWithVRAttenuatedSupported) { EXPECT_CALL(app_manager_mock_, is_attenuated_supported()) .WillRepeatedly(Return(true)); - TestMixState<am::VRHmiState, am::NaviStreamingHmiState>( + TestMixState<am::VRHmiState, am::VideoStreamingHmiState>( &StateControllerImplTest::PrepareVRTTSHMIStateResults); } @@ -2300,7 +2409,7 @@ TEST_F(StateControllerImplTest, EXPECT_CALL(app_manager_mock_, is_attenuated_supported()) .WillRepeatedly(Return(false)); - TestMixState<am::TTSHmiState, am::NaviStreamingHmiState>( + TestMixState<am::TTSHmiState, am::VideoStreamingHmiState>( &StateControllerImplTest::PrepareVRTTSHMIStateResults); } @@ -2308,7 +2417,7 @@ TEST_F(StateControllerImplTest, MixNaviStreamingWithTTSAttenueatedSupported) { EXPECT_CALL(app_manager_mock_, is_attenuated_supported()) .WillRepeatedly(Return(true)); - TestMixState<am::TTSHmiState, am::NaviStreamingHmiState>( + TestMixState<am::TTSHmiState, am::VideoStreamingHmiState>( &StateControllerImplTest::PrepareNaviStreamTTSStateResult); } @@ -2333,7 +2442,7 @@ TEST_F(StateControllerImplTest, EXPECT_CALL(app_manager_mock_, is_attenuated_supported()) .WillRepeatedly(Return(false)); - TestMixState<am::SafetyModeHmiState, am::NaviStreamingHmiState>( + TestMixState<am::SafetyModeHmiState, am::VideoStreamingHmiState>( &StateControllerImplTest::PrepareVRTTSHMIStateResults); } @@ -2342,7 +2451,7 @@ TEST_F(StateControllerImplTest, EXPECT_CALL(app_manager_mock_, is_attenuated_supported()) .WillRepeatedly(Return(true)); - TestMixState<am::SafetyModeHmiState, am::NaviStreamingHmiState>( + TestMixState<am::SafetyModeHmiState, am::VideoStreamingHmiState>( &StateControllerImplTest::PrepareVRTTSHMIStateResults); } @@ -2394,6 +2503,7 @@ TEST_F(StateControllerImplTest, SetRegularStateWithAudioStateAudible) { HmiStatePtr check_state = createHmiState(HMILevel::HMI_BACKGROUND, AudioStreamingState::AUDIBLE, + VideoStreamingState::STREAMABLE, SystemContext::SYSCTXT_MAIN); EXPECT_CALL(*simple_app_ptr_, RegularHmiState()) .WillRepeatedly(Return(BackgroundState())); @@ -2404,7 +2514,9 @@ TEST_F(StateControllerImplTest, SetRegularStateWithAudioStateAudible) { EXPECT_CALL(*simple_app_ptr_, SetRegularState(Truly(HmiStatesComparator(check_state)))); - state_ctrl_->SetRegularState(simple_app_, AudioStreamingState::AUDIBLE); + state_ctrl_->SetRegularState(simple_app_, + AudioStreamingState::AUDIBLE, + VideoStreamingState::STREAMABLE); } TEST_F(StateControllerImplTest, @@ -2753,6 +2865,7 @@ TEST_F(StateControllerImplTest, OnEventOnAppDeactivatedAudioApplication) { const HmiStatePtr state = createHmiState(mobile_apis::HMILevel::HMI_LIMITED, mobile_apis::AudioStreamingState::AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, mobile_apis::SystemContext::SYSCTXT_MAIN); // OnAppDeactivated EXPECT_CALL(app_manager_mock_, application(app_id)) @@ -2781,6 +2894,7 @@ TEST_F(StateControllerImplTest, OnEventOnAppDeactivatedNotAudioApplication) { const HmiStatePtr state = createHmiState(mobile_apis::HMILevel::HMI_BACKGROUND, mobile_apis::AudioStreamingState::NOT_AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, mobile_apis::SystemContext::SYSCTXT_MAIN); // OnAppDeactivated EXPECT_CALL(app_manager_mock_, application(app_id)) @@ -2844,9 +2958,11 @@ TEST_F(StateControllerImplTest, OnEventOnAppActivated) { } TEST_F(StateControllerImplTest, IsStateActive) { - HmiStatePtr state = createHmiState(mobile_apis::HMILevel::HMI_FULL, - mobile_apis::AudioStreamingState::AUDIBLE, - mobile_apis::SystemContext::SYSCTXT_MAIN); + HmiStatePtr state = + createHmiState(mobile_apis::HMILevel::HMI_FULL, + mobile_apis::AudioStreamingState::AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, + mobile_apis::SystemContext::SYSCTXT_MAIN); state->set_state_id(HmiState::STATE_ID_CURRENT); EXPECT_TRUE(state_ctrl_->IsStateActive(state->state_id())); state->set_state_id(HmiState::STATE_ID_REGULAR); @@ -2855,9 +2971,10 @@ TEST_F(StateControllerImplTest, IsStateActive) { EXPECT_FALSE(state_ctrl_->IsStateActive(state->state_id())); } -TEST_F(StateControllerImplTest, IsStateActiveApplyCorrectTempStates) { +TEST_F(StateControllerImplTest, DISABLED_IsStateActiveApplyCorrectTempStates) { InsertApplication(simple_app_); - ApplyTempStatesForApplication(*simple_app_ptr_, valid_state_ids_); + ApplyTempStatesForApplication( + simple_app_, *simple_app_ptr_, valid_state_ids_); std::vector<am::HmiState::StateID>::const_iterator it = valid_state_ids_.begin(); for (; it != valid_state_ids_.end(); ++it) { @@ -2906,6 +3023,7 @@ TEST_F(StateControllerImplTest, OnApplicationRegisteredDifferentStates) { const am::HmiStatePtr old_state = CreateHmiStateByHmiStateType<am::HmiState>( mobile_apis::HMILevel::HMI_FULL, mobile_apis::AudioStreamingState::AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, mobile_apis::SystemContext::SYSCTXT_MAIN, simple_app_); @@ -2918,6 +3036,7 @@ TEST_F(StateControllerImplTest, OnApplicationRegisteredDifferentStates) { CreateHmiStateByHmiStateType<am::HmiState>( mobile_apis::HMILevel::HMI_BACKGROUND, mobile_apis::AudioStreamingState::AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, mobile_apis::SystemContext::SYSCTXT_MAIN, simple_app_); @@ -2955,6 +3074,7 @@ TEST_F(StateControllerImplTest, OnApplicationRegisteredEqualStates) { const am::HmiStatePtr old_state = CreateHmiStateByHmiStateType<am::HmiState>( mobile_apis::HMILevel::HMI_FULL, mobile_apis::AudioStreamingState::AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, mobile_apis::SystemContext::SYSCTXT_MAIN, simple_app_); @@ -2967,6 +3087,7 @@ TEST_F(StateControllerImplTest, OnApplicationRegisteredEqualStates) { CreateHmiStateByHmiStateType<am::HmiState>( mobile_apis::HMILevel::HMI_BACKGROUND, mobile_apis::AudioStreamingState::AUDIBLE, + mobile_apis::VideoStreamingState::NOT_STREAMABLE, mobile_apis::SystemContext::SYSCTXT_MAIN, simple_app_); EXPECT_CALL(*simple_app_ptr_, RegularHmiState()) diff --git a/src/components/connection_handler/src/connection.cc b/src/components/connection_handler/src/connection.cc index 16b88c4164..614120312a 100644 --- a/src/components/connection_handler/src/connection.cc +++ b/src/components/connection_handler/src/connection.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Ford Motor Company + * Copyright (c) 2018, Ford Motor Company * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index c7a50199b1..f6f06bd7cd 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -672,6 +672,7 @@ class ApplicationManager { utils::SharedPtr<Application> app, mobile_apis::HMILevel::eType hmi_level, mobile_apis::AudioStreamingState::eType audio_state, + mobile_apis::VideoStreamingState::eType video_state, mobile_apis::SystemContext::eType system_context) const = 0; /** @@ -730,6 +731,10 @@ class ApplicationManager { virtual void OnTimerSendTTSGlobalProperties() = 0; virtual void OnLowVoltage() = 0; virtual void OnWakeUp() = 0; + + virtual bool IsSOStructValid( + const hmi_apis::StructIdentifiers::eType struct_id, + const smart_objects::SmartObject& display_capabilities) = 0; }; } // namespace application_manager 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 f0859ece38..d48c7307b9 100644 --- a/src/components/include/application_manager/policies/policy_handler_interface.h +++ b/src/components/include/application_manager/policies/policy_handler_interface.h @@ -49,6 +49,7 @@ #include "smart_objects/smart_object.h" #include "policy/policy_types.h" #include "policy/policy_table/types.h" +#include "policy/cache_manager_interface.h" using namespace ::rpc::policy_table_interface_base; namespace policy { @@ -391,6 +392,32 @@ class PolicyHandlerInterface { mobile_apis::RequestType::eType type) const = 0; /** + * @brief Checks if certain request subtype is allowed for application + * @param policy_app_id Unique applicaion id + * @param request_subtype Request subtype + * @return true, if allowed, otherwise - false + */ + virtual bool IsRequestSubTypeAllowed( + const std::string& policy_app_id, + const std::string& request_subtype) const = 0; + + /** + * @brief Gets application request types state + * @param policy_app_id Unique application id + * @return request types state + */ + virtual RequestType::State GetAppRequestTypeState( + const std::string& policy_app_id) const = 0; + + /** + * @brief Gets application request subtypes state + * @param policy_app_id Unique application id + * @return request subtypes state + */ + virtual RequestSubType::State GetAppRequestSubTypeState( + const std::string& policy_app_id) const = 0; + + /** * @brief Gets application request types * @param policy_app_id Unique application id * @return request types @@ -399,6 +426,14 @@ class PolicyHandlerInterface { const std::string& policy_app_id) const = 0; /** + * @brief Gets application request subtypes + * @param policy_app_id Unique application id + * @return app request subtypes + */ + virtual const std::vector<std::string> GetAppRequestSubTypes( + const std::string& policy_app_id) const = 0; + + /** * @brief Gets vehicle information * @return Structure with vehicle information */ diff --git a/src/components/include/application_manager/state_controller.h b/src/components/include/application_manager/state_controller.h index 2fe0492b42..8f608488e9 100644 --- a/src/components/include/application_manager/state_controller.h +++ b/src/components/include/application_manager/state_controller.h @@ -49,6 +49,7 @@ class StateController { ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state, const bool SendActivateApp) = 0; virtual void SetRegularState(ApplicationSharedPtr app, @@ -58,6 +59,7 @@ class StateController { ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state, const mobile_apis::SystemContext::eType system_context, const bool SendActivateApp) = 0; @@ -67,7 +69,8 @@ class StateController { virtual void SetRegularState( ApplicationSharedPtr app, - const mobile_apis::AudioStreamingState::eType audio_state) = 0; + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state) = 0; virtual void SetRegularState( ApplicationSharedPtr app, @@ -82,9 +85,17 @@ class StateController { virtual int64_t SendBCActivateApp(ApplicationConstSharedPtr app, hmi_apis::Common_HMILevel::eType level, bool send_policy_priority) = 0; + /** + * @brief OnVideoStreamingStarted process video streaming started + * @param app projection or navigation application starting streaming + */ + virtual void OnVideoStreamingStarted(ApplicationConstSharedPtr app) = 0; - virtual void OnNaviStreamingStarted() = 0; - virtual void OnNaviStreamingStopped() = 0; + /** + * @brief OnVideoStreamingStopped process video streaming stopped + * @param app projection or navigation application stopping streaming + */ + virtual void OnVideoStreamingStopped(ApplicationConstSharedPtr app) = 0; virtual void OnStateChanged(ApplicationSharedPtr app, HmiStatePtr old_state, HmiStatePtr new_state) = 0; 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 24905671fa..7970d525c5 100644 --- a/src/components/include/policy/policy_external/policy/policy_manager.h +++ b/src/components/include/policy/policy_external/policy/policy_manager.h @@ -41,6 +41,7 @@ #include "policy/policy_table/types.h" #include "policy/policy_listener.h" #include "policy/usage_statistics/statistics_manager.h" +#include "policy/cache_manager_interface.h" #ifdef SDL_REMOTE_CONTROL #include "policy/access_remote.h" @@ -487,6 +488,22 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string& device_id_to) = 0; /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + virtual RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const = 0; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + virtual RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const = 0; + + /** * @brief Gets request types for application * @param policy_app_id Unique application id * @return request types of application @@ -495,6 +512,14 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string policy_app_id) const = 0; /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @return request subtypes of application + */ + virtual const std::vector<std::string> GetAppRequestSubTypes( + const std::string& policy_app_id) const = 0; + + /** * @brief Get information about vehicle * @return vehicle information */ 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 3e90cfc094..84d48a691e 100644 --- a/src/components/include/policy/policy_regular/policy/policy_manager.h +++ b/src/components/include/policy/policy_regular/policy/policy_manager.h @@ -41,6 +41,8 @@ #include "policy/policy_table/types.h" #include "policy/policy_listener.h" #include "policy/usage_statistics/statistics_manager.h" +#include "policy/cache_manager_interface.h" + #ifdef SDL_REMOTE_CONTROL #include "policy/access_remote.h" #endif // SDL_REMOTE_CONTROL @@ -466,6 +468,22 @@ class PolicyManager : public usage_statistics::StatisticsManager { virtual void OnAppsSearchCompleted(const bool trigger_ptu) = 0; /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + virtual RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const = 0; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + virtual RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const = 0; + + /** * @brief Gets request types for application * @param policy_app_id Unique application id * @return request types of application @@ -474,6 +492,14 @@ class PolicyManager : public usage_statistics::StatisticsManager { const std::string policy_app_id) const = 0; /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @return request subtypes of application + */ + virtual const std::vector<std::string> GetAppRequestSubTypes( + const std::string& policy_app_id) const = 0; + + /** * @brief Get information about vehicle * @return vehicle information */ 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 452a1e6c39..bc1c0d08d2 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -248,11 +248,12 @@ class MockApplicationManager : public application_manager::ApplicationManager { void(uint32_t app_id, protocol_handler::ServiceType service_type, bool state)); - MOCK_CONST_METHOD4(CreateRegularState, + MOCK_CONST_METHOD5(CreateRegularState, application_manager::HmiStatePtr( application_manager::ApplicationSharedPtr app, mobile_apis::HMILevel::eType hmi_level, mobile_apis::AudioStreamingState::eType audio_state, + mobile_apis::VideoStreamingState::eType video_state, mobile_apis::SystemContext::eType system_context)); DEPRECATED MOCK_CONST_METHOD4( CreateRegularState, @@ -273,6 +274,10 @@ class MockApplicationManager : public application_manager::ApplicationManager { MOCK_METHOD0(event_dispatcher, application_manager::event_engine::EventDispatcher&()); + MOCK_METHOD2(IsSOStructValid, + bool(const hmi_apis::StructIdentifiers::eType struct_id, + const smart_objects::SmartObject& display_capabilities)); + DEPRECATED MOCK_CONST_METHOD1(IsAppSubscribedForWayPoints, bool(const uint32_t)); DEPRECATED MOCK_METHOD1(SubscribeAppForWayPoints, void(const uint32_t)); diff --git a/src/components/include/test/application_manager/mock_state_controller.h b/src/components/include/test/application_manager/mock_state_controller.h index 9f8d94599b..0165180a0a 100644 --- a/src/components/include/test/application_manager/mock_state_controller.h +++ b/src/components/include/test/application_manager/mock_state_controller.h @@ -51,27 +51,30 @@ class MockStateController : public am::StateController { void(am::ApplicationSharedPtr app, am::HmiStatePtr state, const bool SendActivateApp)); - MOCK_METHOD4(SetRegularState, + MOCK_METHOD5(SetRegularState, void(am::ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state, const bool SendActivateApp)); MOCK_METHOD3(SetRegularState, void(am::ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, const bool SendActivateApp)); - MOCK_METHOD5(SetRegularState, + MOCK_METHOD6(SetRegularState, void(am::ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state, const mobile_apis::SystemContext::eType system_context, const bool SendActivateApp)); MOCK_METHOD2(SetRegularState, void(am::ApplicationSharedPtr app, const mobile_apis::HMILevel::eType hmi_level)); - MOCK_METHOD2(SetRegularState, + MOCK_METHOD3(SetRegularState, void(am::ApplicationSharedPtr app, - const mobile_apis::AudioStreamingState::eType audio_state)); + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state)); MOCK_METHOD2(SetRegularState, void(am::ApplicationSharedPtr app, const mobile_apis::SystemContext::eType system_context)); @@ -84,8 +87,10 @@ class MockStateController : public am::StateController { int64_t(am::ApplicationConstSharedPtr app, hmi_apis::Common_HMILevel::eType level, bool send_policy_priority)); - MOCK_METHOD0(OnNaviStreamingStarted, void()); - MOCK_METHOD0(OnNaviStreamingStopped, void()); + MOCK_METHOD1(OnVideoStreamingStarted, + void(am::ApplicationConstSharedPtr app)); + MOCK_METHOD1(OnVideoStreamingStopped, + void(am::ApplicationConstSharedPtr app)); MOCK_METHOD3(OnStateChanged, void(am::ApplicationSharedPtr app, am::HmiStatePtr old_state, 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 931fd6cfb4..dfd537c678 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 @@ -197,6 +197,18 @@ class MockPolicyHandlerInterface : public policy::PolicyHandlerInterface { MOCK_CONST_METHOD2(IsRequestTypeAllowed, bool(const std::string& policy_app_id, mobile_apis::RequestType::eType type)); + MOCK_CONST_METHOD2(IsRequestSubTypeAllowed, + bool(const std::string& policy_app_id, + const std::string& request_subtype)); + MOCK_CONST_METHOD1( + GetAppRequestTypeState, + policy::RequestType::State(const std::string& policy_app_id)); + MOCK_CONST_METHOD1( + GetAppRequestSubTypeState, + policy::RequestSubType::State(const std::string& policy_app_id)); + MOCK_CONST_METHOD1( + GetAppRequestSubTypes, + const std::vector<std::string>(const std::string& policy_app_id)); MOCK_CONST_METHOD1( GetAppRequestTypes, const std::vector<std::string>(const std::string& policy_app_id)); 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 5aa92446b6..02931114f0 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 @@ -250,6 +250,13 @@ class MockCacheManagerInterface : public ::policy::CacheManagerInterface { MOCK_METHOD2(OnDeviceSwitching, void(const std::string& device_id_from, const std::string& device_id_to)); + MOCK_CONST_METHOD2(GetAppRequestSubTypes, + void(const std::string& policy_app_id, + std::vector<std::string>& request_subtypes)); + MOCK_CONST_METHOD1(GetAppRequestTypesState, + RequestType::State(const std::string& policy_app_id)); + MOCK_CONST_METHOD1(GetAppRequestSubTypesState, + RequestSubType::State(const std::string& policy_app_id)); }; } // namespace policy_test diff --git a/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_external/policy/mock_policy_manager.h index 9e487da4ba..96e484acae 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 @@ -218,6 +218,13 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(OnDeviceSwitching, void(const std::string& device_id_from, const std::string& device_id_to)); + MOCK_CONST_METHOD1( + GetAppRequestSubTypes, + const std::vector<std::string>(const std::string& policy_app_id)); + MOCK_CONST_METHOD1(GetAppRequestTypesState, + RequestType::State(const std::string& policy_app_id)); + MOCK_CONST_METHOD1(GetAppRequestSubTypesState, + RequestSubType::State(const std::string& policy_app_id)); }; } // 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 ed3a5088c1..cf20dcb666 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 @@ -214,6 +214,13 @@ class MockCacheManagerInterface : public CacheManagerInterface { MOCK_METHOD2(OnDeviceSwitching, void(const std::string& device_id_from, const std::string& device_id_to)); + MOCK_CONST_METHOD2(GetAppRequestSubTypes, + void(const std::string& policy_app_id, + std::vector<std::string>& request_subtypes)); + MOCK_CONST_METHOD1(GetAppRequestTypesState, + RequestType::State(const std::string& policy_app_id)); + MOCK_CONST_METHOD1(GetAppRequestSubTypesState, + RequestSubType::State(const std::string& policy_app_id)); }; } // namespace policy_test diff --git a/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h b/src/components/include/test/policy/policy_regular/policy/mock_policy_manager.h index 82012b83c7..0b8823d307 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 @@ -226,6 +226,14 @@ class MockPolicyManager : public PolicyManager { MOCK_METHOD2(OnDeviceSwitching, void(const std::string& device_id_from, const std::string& device_id_to)); + + MOCK_CONST_METHOD1( + GetAppRequestSubTypes, + const std::vector<std::string>(const std::string& policy_app_id)); + MOCK_CONST_METHOD1(GetAppRequestTypesState, + RequestType::State(const std::string& policy_app_id)); + MOCK_CONST_METHOD1(GetAppRequestSubTypesState, + RequestSubType::State(const std::string& policy_app_id)); }; } // namespace policy_manager_test diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 2b34de0440..0281b50956 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -371,6 +371,7 @@ <element name="LHPLUS_PHONEMES" /> <element name="PRE_RECORDED" /> <element name="SILENCE" /> + <element name="FILE" /> </enum> <enum name="VrCapabilities"> @@ -781,6 +782,33 @@ </element> </enum> +<enum name="TPMS"> + <element name="UNKNOWN"> + <description>If set the status of the tire is not known.</description> + </element> + <element name="SYSTEM_FAULT"> + <description>TPMS does not function.</description> + </element> + <element name="SENSOR_FAULT"> + <description>The sensor of the tire does not function.</description> + </element> + <element name="LOW"> + <description>TPMS is reporting a low tire pressure for the tire.</description> + </element> + <element name="SYSTEM_ACTIVE"> + <description>TPMS is active and the tire pressure is monitored.</description> + </element> + <element name="TRAIN"> + <description>TPMS is reporting that the tire must be trained.</description> + </element> + <element name="TRAINING_COMPLETE"> + <description>TPMS reports the training for the tire is completed.</description> + </element> + <element name="NOT_TRAINED"> + <description>TPMS reports the tire is not trained.</description> + </element> +</enum> + <enum name="PRNDL"> <description>The selected gear.</description> <element name="PARK"> @@ -1137,13 +1165,13 @@ </enum> <enum name="RequestType"> - <description>Enumeration listing possible asynchronous requests.</description> - <element name="HTTP" /> - <element name="FILE_RESUME" /> - <element name="AUTH_REQUEST" /> - <element name="AUTH_CHALLENGE" /> - <element name="AUTH_ACK" /> - <element name="PROPRIETARY" /> + <description>Enumeration listing possible asynchronous requests.</description> + <element name="HTTP" /> + <element name="FILE_RESUME" /> + <element name="AUTH_REQUEST" /> + <element name="AUTH_CHALLENGE" /> + <element name="AUTH_ACK" /> + <element name="PROPRIETARY" /> <element name="QUERY_APPS" /> <element name="LAUNCH_APP" /> <element name="LOCK_SCREEN_ICON_URL" /> @@ -1158,6 +1186,7 @@ <element name="EMERGENCY" /> <element name="MEDIA" /> <element name="FOTA" /> + <element name="OEM_SPECIFIC"/> </enum> <enum name="ECallConfirmationStatus"> @@ -1856,6 +1885,9 @@ <param name="imageType" type="Common.ImageType" mandatory="true"> <description>Describes, whether it is a static or dynamic image.</description> </param> + <param name="isTemplate" type="Boolean" mandatory="false"> + <description>Optional value to specify whether it's a template image. A template image can be (re)colored by the HMI as needed by using an image pattern</description> + </param> </struct> <struct name="DeviceInfo"> @@ -1896,12 +1928,12 @@ </struct> <struct name="TTSChunk"> - <description>A TTS chunk, that consists of the text/phonemes to be spoken</description> + <description>A TTS chunk, that consists of text/phonemes to speak or the name of a file to play, and a TTS type (like text or SAPI)</description> <param name="text" type="String" mandatory="true" maxlength="500"> - <description>The text or phonemes to be spoken.</description> + <description>The text or phonemes to be spoken, or the name of an audio file to play.</description> </param> <param name="type" type="Common.SpeechCapabilities" mandatory="true"> - <description>Describes, whether it is text or a specific phoneme set. See SpeechCapabilities.</description> + <description>Describes whether the TTS chunk is plain text, a specific phoneme set, or an audio file. See SpeechCapabilities.</description> </param> </struct> @@ -1983,6 +2015,14 @@ <description>If SDL omits this parameter - none RequestType is allowed for this app</description> <description>(either this is a pre-registered app or such is dictated by policies).</description> </param> + <param name="requestSubType" type="String" maxlength="100" minsize="0" maxsize="100" array="true" mandatory="false"> + <description> + The list of SystemRequest's requestSubTypes allowed by policies for the named application. + If the app sends a requestSubType which is not specified in this list, then that request should be rejected. + An empty array signifies that any value of requestSubType is allowed for this app. + If this parameter is omitted, then a request with any value of requestSubType is now allowed for this app + </description> + </param> <param name="dayColorScheme" type="Common.TemplateColorScheme" mandatory="false"></param> <param name="nightColorScheme" type="Common.TemplateColorScheme" mandatory="false"></param> </struct> @@ -2117,6 +2157,9 @@ <param name="displayType" type="Common.DisplayType" mandatory="true"> <description>The type of the display. See DisplayType</description> </param> + <param name="displayName" type="String" mandatory="false"> + <description>The name of the display the app is connected to.</description> + </param> <param name="textFields" type="Common.TextField" minsize="0" maxsize="100" array="true" mandatory="true"> <description>A set of all fields for text displaying supported by HU. See TextFieldName.</description> <description>If there are no textfields supported, the empty array must be returned</description> @@ -2311,7 +2354,13 @@ <struct name="SingleTireStatus"> <param name="status" type="Common.ComponentVolumeStatus" mandatory="true"> <description>The status of component volume. See ComponentVolumeStatus.</description> -</param> + </param> + <param name="tpms" type="TPMS" mandatory="false"> + <description>The status of TPMS according to the particular tire.</description> + </param> + <param name="pressure" type="Float" mandatory="false" minvalue="0" maxvalue="2000"> + <description>The pressure value of the particular tire in kilo pascal.</description> + </param> </struct> <struct name="DIDResult"> @@ -2986,6 +3035,11 @@ <param name="requestType" type="Common.RequestType" mandatory="true"> <description>The type of system request.</description> </param> + <param name="requestSubType" type="String" maxlength="255" mandatory="false"> + <description> + This parameter is filled for supporting OEM proprietary data exchanges. + </description> + </param> <param name="url" type="String" maxlength="1000" minlength="1" mandatory="false"> <description>Optional array of URL(s) for HTTP requests.</description> </param> @@ -3012,6 +3066,11 @@ <param name="requestType" type="Common.RequestType" mandatory="true"> <description>The type of system request.</description> </param> + <param name="requestSubType" type="String" maxlength="255" mandatory="false"> + <description> + This parameter is filled for supporting OEM proprietary data exchanges. + </description> + </param> <param name="fileName" type="String" maxlength="255" minlength="1" mandatory="true"> <description>The path to file.</description> </param> @@ -3290,10 +3349,10 @@ <description>Method is invoked at system start-up. SDL requests the information about all supported hardware and their capabilities</description> </function> <function name="GetCapabilities" messagetype="response"> - <param name="speechCapabilities" type="Common.SpeechCapabilities" minsize="1" maxsize="5" array="true" mandatory="true"> + <param name="speechCapabilities" type="Common.SpeechCapabilities" minsize="1" maxsize="100" array="true" mandatory="true"> <description>See SpeechCapabilities</description> </param> - <param name="prerecordedSpeechCapabilities" type="Common.PrerecordedSpeech" minsize="1" maxsize="5" array="true" mandatory="true"> + <param name="prerecordedSpeechCapabilities" type="Common.PrerecordedSpeech" minsize="1" maxsize="100" array="true" mandatory="true"> <description>See PrerecordedSpeech</description> </param> </function> @@ -4937,6 +4996,14 @@ If SDL omits this parameter - nothing is changed for RequestType in the policies </description> </param> + <param name="requestSubType" type="String" maxlength="100" minsize="0" maxsize="100" array="true" mandatory="false"> + <description> + The list of SystemRequest's requestSubTypes allowed by policies for the named application. + If the app sends a requestSubType which is not specified in this list, then that request should be rejected. + An empty array signifies that any value of requestSubType is allowed for this app. + If this parameter is omitted, then a request with any value of requestSubType is now allowed for this app + </description> + </param> </function> <function name="OnSDLConsentNeeded" messagetype="notification"> diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index 2cbae29c8c..8b8da6a63a 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -361,6 +361,12 @@ <element name="ATTENUATED" /> <element name="NOT_AUDIBLE" /> </enum> + + <enum name="VideoStreamingState"> + <description>Enumeration that describes possible states of video streaming. </description> + <element name="STREAMABLE" /> + <element name="NOT_STREAMABLE" /> + </enum> <enum name="SystemAction"> <description>Enumeration that describes system actions that can be triggered.</description> @@ -441,6 +447,7 @@ <element name="LHPLUS_PHONEMES" /> <element name="PRE_RECORDED" /> <element name="SILENCE" /> + <element name="FILE" /> </enum> <enum name="VrCapabilities"> @@ -908,6 +915,9 @@ <param name="imageType" type="ImageType" mandatory="true"> <description>Describes, whether it is a static or dynamic image.</description> </param> + <param name="isTemplate" type="Boolean" mandatory="false"> + <description>Optional value to specify whether it's a template image. A template image can be (re)colored by the HMI as needed by using an image pattern</description> + </param> </struct> <struct name="SoftButton"> @@ -1091,6 +1101,33 @@ <element name="NOT_SUPPORTED" internal_name="CVS_NOT_SUPPORTED"> </element> </enum> + + <enum name="TPMS"> + <element name="UNKNOWN"> + <description>If set the status of the tire is not known.</description> + </element> + <element name="SYSTEM_FAULT"> + <description>TPMS does not function.</description> + </element> + <element name="SENSOR_FAULT"> + <description>The sensor of the tire does not function.</description> + </element> + <element name="LOW"> + <description>TPMS is reporting a low tire pressure for the tire.</description> + </element> + <element name="SYSTEM_ACTIVE"> + <description>TPMS is active and the tire pressure is monitored.</description> + </element> + <element name="TRAIN"> + <description>TPMS is reporting that the tire must be trained.</description> + </element> + <element name="TRAINING_COMPLETE"> + <description>TPMS reports the training for the tire is completed.</description> + </element> + <element name="NOT_TRAINED"> + <description>TPMS reports the tire is not trained.</description> + </element> + </enum> <enum name="FuelType"> <element name="GASOLINE" /> @@ -1126,6 +1163,12 @@ <param name="status" type="ComponentVolumeStatus" mandatory="true"> <description>See ComponentVolumeStatus.</description> </param> + <param name="tpms" type="TPMS" mandatory="false"> + <description>The status of TPMS according to the particular tire.</description> + </param> + <param name="pressure" type="Float" mandatory="false" minvalue="0" maxvalue="2000"> + <description>The pressure value of the particular tire in kilo pascal.</description> + </param> </struct> <enum name="WarningLightStatus"> @@ -1943,6 +1986,9 @@ <param name="displayType" type="DisplayType" mandatory="true"> <description>The type of the display. See DisplayType</description> </param> + <param name="displayName" type="String" mandatory="false"> + <description>The name of the display the app is connected to.</description> + </param> <param name="textFields" type="TextField" minsize="1" maxsize="100" array="true" mandatory="true"> <description>A set of all fields that support text data. See TextField</description> </param> @@ -2058,15 +2104,15 @@ </param> </struct> <struct name="TTSChunk"> - <description>A TTS chunk, that consists of the text/phonemes to speak and the type (like text or SAPI)</description> + <description>A TTS chunk, that consists of text/phonemes to speak or the name of a file to play, and a TTS type (like text or SAPI)</description> <param name="text" minlength="0" maxlength="500" type="String" mandatory="true"> <description> - The text or phonemes to speak. + The text or phonemes to speak, or the name of the audio file to play. May not be empty. </description> </param> <param name="type" type="SpeechCapabilities" mandatory="true"> - <description>Describes, whether it is text or a specific phoneme set. See SpeechCapabilities</description> + <description>Describes whether the TTS chunk is plain text, a specific phoneme set, or an audio file. See SpeechCapabilities</description> </param> </struct> <struct name="Turn"> @@ -2183,6 +2229,7 @@ <element name="EMERGENCY" /> <element name="MEDIA" /> <element name="FOTA" /> + <element name="OEM_SPECIFIC" /> </enum> <enum name="AppHMIType"> <description>Enumeration listing possible app types.</description> @@ -3153,6 +3200,10 @@ <param name="systemSoftwareVersion" type="String" maxlength="100" mandatory="false" platform="documentation"> <description>The software version of the system that implements the SmartDeviceLink core.</description> </param> + <param name="iconResumed" type="Boolean" mandatory="true"> + <description>Existence of apps icon at system. If true, apps icon + was resumed at system. If false, apps icon is not resumed at system</description> + </param> </function> <function name="UnregisterAppInterface" functionID="UnregisterAppInterfaceID" messagetype="request"> @@ -5401,6 +5452,11 @@ Note that Proprietary requests should forward the binary data to the known proprietary module on the system. </description> </param> + <param name="requestSubType" type="String" maxlength="255" mandatory="false"> + <description> + This parameter is filled for supporting OEM proprietary data exchanges. + </description> + </param> <param name="fileName" type="String" maxlength="255" mandatory="false"> <description> Filename of HTTP data to store in predefined system staging area. @@ -5801,6 +5857,9 @@ <param name="systemContext" type="SystemContext" mandatory="true"> <description>See SystemContext</description> </param> + <param name="videoStreamingState" type="VideoStreamingState" mandatory="true"> + <description>See VideoStreamingState. If it is NOT_STREAMABLE, the app must stop streaming video to SDL.</description> + </param> </function> <function name="OnAppInterfaceUnregistered" functionID="OnAppInterfaceUnregisteredID" messagetype="notification"> @@ -6000,6 +6059,11 @@ <param name="requestType" type="RequestType" mandatory="true"> <description>The type of system request.</description> </param> + <param name="requestSubType" type="String" maxlength="255" mandatory="false"> + <description> + This parameter is filled for supporting OEM proprietary data exchanges. + </description> + </param> <param name="url" type="String" maxlength="1000" mandatory="false"> <description> Optional URL for HTTP requests. 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 bda456c90a..f41ddb14cd 100644 --- a/src/components/policy/policy_external/include/policy/cache_manager.h +++ b/src/components/policy/policy_external/include/policy/cache_manager.h @@ -84,6 +84,22 @@ class CacheManager : public CacheManagerInterface { CheckPermissionResult& result); /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Returns true if Policy Table was not updated yet * from preloaded pt file. */ @@ -642,8 +658,18 @@ class CacheManager : public CacheManagerInterface { * @param policy_app_id Unique application id * @param request_types Request types of application */ - void GetAppRequestTypes(const std::string& policy_app_id, - std::vector<std::string>& request_types) const; + void GetAppRequestTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_types) const OVERRIDE; + + /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @param request_subtypes Request subtypes of application to be filled + */ + void GetAppRequestSubTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_subtypes) const OVERRIDE; virtual const MetaInfo GetMetaInfo() const OVERRIDE; 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 b9e9f73646..1d74780f19 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 @@ -47,6 +47,16 @@ namespace policy_table = rpc::policy_table_interface_base; namespace policy { +namespace RequestType { +// Describes available RequestType states in policy table +enum class State { UNAVAILABLE = 0, AVAILABLE, EMPTY, OMITTED }; +} // namespace RequestType + +namespace RequestSubType { +// Describes available RequestSubType states in policy table +enum class State { UNAVAILABLE = 0, AVAILABLE, EMPTY, OMITTED }; +} // namespace RequestSubType + class CacheManagerInterface { public: virtual ~CacheManagerInterface() {} @@ -79,6 +89,21 @@ class CacheManagerInterface { const PTString& hmi_level, const PTString& rpc, CheckPermissionResult& result) = 0; + /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + virtual RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const = 0; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + virtual RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const = 0; /** * @brief Returns true if Policy Table was not updated yet @@ -706,6 +731,15 @@ class CacheManagerInterface { std::vector<std::string>& request_types) const = 0; /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @param request_subtypes Request subtypes of application to be filled + */ + virtual void GetAppRequestSubTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_subtypes) const = 0; + + /** * @brief Gets meta information * @return meta information */ diff --git a/src/components/policy/policy_external/include/policy/policy_helper.h b/src/components/policy/policy_external/include/policy/policy_helper.h index 6945f45b45..e399b44719 100644 --- a/src/components/policy/policy_external/include/policy/policy_helper.h +++ b/src/components/policy/policy_external/include/policy/policy_helper.h @@ -192,6 +192,14 @@ struct CheckAppPolicy { */ bool IsRequestTypeChanged(const AppPoliciesValueType& app_policy) const; + /** + * @brief Checks whether App RequestSubTypes have been changed by + * udpated + * @param app_policy Reference to updated application policy + * @return True if changed, otherwise - false + */ + bool IsRequestSubTypeChanged(const AppPoliciesValueType& app_policy) const; + private: PolicyManagerImpl* pm_; const utils::SharedPtr<policy_table::Table> update_; 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 97a2e60055..fcd9c9f69a 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 @@ -538,6 +538,22 @@ class PolicyManagerImpl : public PolicyManager { void OnAppsSearchCompleted(const bool trigger_ptu) OVERRIDE; /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Gets request types for application * @param policy_app_id Unique application id * @return request types of application @@ -546,6 +562,14 @@ class PolicyManagerImpl : public PolicyManager { const std::string policy_app_id) const OVERRIDE; /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @return request subtypes of application + */ + const std::vector<std::string> GetAppRequestSubTypes( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Get information about vehicle * @return vehicle information */ diff --git a/src/components/policy/policy_external/include/policy/policy_table/enums.h b/src/components/policy/policy_external/include/policy/policy_table/enums.h index fa37cfe7a5..96a6748436 100644 --- a/src/components/policy/policy_external/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_external/include/policy/policy_table/enums.h @@ -149,7 +149,9 @@ enum RequestType { RT_VEHICLE_DIAGNOSTICS, RT_EMERGENCY, RT_MEDIA, - RT_FOTA + RT_FOTA, + RT_OEM_SPECIFIC, + RT_EMPTY // Added to allow empty Request Types handling }; bool IsValidEnum(RequestType val); 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 53f5a35b99..1b1419365d 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 @@ -78,7 +78,7 @@ typedef Map<URL, 1, 255> URLList; typedef Map<URLList, 1, 255> ServiceEndpoints; typedef uint8_t NumberOfNotificationsType; -typedef Map<Integer<NumberOfNotificationsType, 0, 255>, 0, 6> +typedef Map<Integer<NumberOfNotificationsType, 0, 255>, 0, 7> NumberOfNotificationsPerMinute; typedef Array<Integer<uint16_t, 1, 1000>, 0, 5> SecondsBetweenRetries; @@ -102,6 +102,8 @@ typedef Map<DeviceParams, 0, 255> DeviceData; typedef Array<Enum<RequestType>, 0, 255> RequestsTypeArray; +typedef Strings RequestSubTypes; + #ifdef SDL_REMOTE_CONTROL typedef Map<Strings, 0, 255> RemoteRpcs; typedef Map<RemoteRpcs, 0, 255> AccessModules; @@ -173,6 +175,7 @@ struct ApplicationParams : PolicyBase { Optional<Strings> nicknames; Optional<AppHMITypes> AppHMIType; Optional<RequestTypes> RequestType; + Optional<RequestSubTypes> RequestSubType; Optional<Integer<uint16_t, 0, 65225> > memory_kb; Optional<Integer<uint32_t, 0, UINT_MAX> > heart_beat_timeout_ms; #ifdef SDL_REMOTE_CONTROL 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 8d5a7054f1..577f15c3f5 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 @@ -130,7 +130,7 @@ minsize="1" maxsize="255" /> <typedef name="NumberOfNotificationsPerMinute" type="Integer" - map="true" maxsize="6" minvalue="0" maxvalue="255" /> + map="true" maxsize="7" minvalue="0" maxvalue="255" /> <typedef name="SecondsBetweenRetries" type="Integer" array="true" maxsize="10" minvalue="1" maxvalue="1000" /> 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 232191cfea..9682b3d58d 100644 --- a/src/components/policy/policy_external/include/policy/policy_types.h +++ b/src/components/policy/policy_external/include/policy/policy_types.h @@ -267,7 +267,8 @@ struct AppPermissions { , appRevoked(false) , appPermissionsConsentNeeded(false) , appUnauthorized(false) - , requestTypeChanged(false) {} + , requestTypeChanged(false) + , requestSubTypeChanged(false) {} std::string application_id; bool isAppPermissionsRevoked; @@ -280,6 +281,8 @@ struct AppPermissions { DeviceParams deviceInfo; bool requestTypeChanged; std::vector<std::string> requestType; + bool requestSubTypeChanged; + std::vector<std::string> requestSubType; }; /** @@ -503,7 +506,8 @@ enum PermissionsCheckResult { RESULT_CONSENT_NEEDED, RESULT_CONSENT_NOT_REQIURED, RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED, - RESULT_REQUEST_TYPE_CHANGED + RESULT_REQUEST_TYPE_CHANGED, + RESULT_REQUEST_SUBTYPE_CHANGED }; /** diff --git a/src/components/policy/policy_external/include/policy/sql_pt_queries.h b/src/components/policy/policy_external/include/policy/sql_pt_queries.h index a69df20cfc..646cc7663b 100644 --- a/src/components/policy/policy_external/include/policy/sql_pt_queries.h +++ b/src/components/policy/policy_external/include/policy/sql_pt_queries.h @@ -65,6 +65,7 @@ extern const std::string kSelectAppGroups; extern const std::string kSelectNicknames; extern const std::string kSelectAppTypes; extern const std::string kSelectRequestTypes; +extern const std::string kSelectRequestSubTypes; extern const std::string kSelectSecondsBetweenRetries; extern const std::string kSelectIgnitionCycles; extern const std::string kSelectKilometers; @@ -78,6 +79,9 @@ extern const std::string kInsertAppGroup; extern const std::string kInsertNickname; extern const std::string kInsertAppType; extern const std::string kInsertRequestType; +extern const std::string kInsertOmittedRequestType; +extern const std::string kInsertOmittedRequestSubType; +extern const std::string kInsertRequestSubType; extern const std::string kInsertMessageType; extern const std::string kInsertLanguage; extern const std::string kInsertMessageString; @@ -98,6 +102,7 @@ extern const std::string kDeleteExternalConsentEntities; extern const std::string kDeleteAppGroup; extern const std::string kDeleteApplication; extern const std::string kDeleteRequestType; +extern const std::string kDeleteRequestSubType; extern const std::string kDeleteDevice; extern const std::string kIncrementIgnitionCycles; extern const std::string kResetIgnitionCycles; diff --git a/src/components/policy/policy_external/include/policy/sql_pt_representation.h b/src/components/policy/policy_external/include/policy/sql_pt_representation.h index 54dfb9f0b7..c32e3205ef 100644 --- a/src/components/policy/policy_external/include/policy/sql_pt_representation.h +++ b/src/components/policy/policy_external/include/policy/sql_pt_representation.h @@ -133,6 +133,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { policy_table::AppHMITypes* app_types) const; bool GatherRequestType(const std::string& app_id, policy_table::RequestTypes* request_types) const; + bool GatherRequestSubType( + const std::string& app_id, + policy_table::RequestSubTypes* request_subtypes) const; bool GatherNickName(const std::string& app_id, policy_table::Strings* nicknames) const; @@ -168,6 +171,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { const policy_table::AppHMITypes& types); bool SaveRequestType(const std::string& app_id, const policy_table::RequestTypes& types); + bool SaveRequestSubType( + const std::string& app_id, + const policy_table::RequestSubTypes& request_subtypes); public: virtual std::string GetLockScreenIconUrl() const; diff --git a/src/components/policy/policy_external/src/cache_manager.cc b/src/components/policy/policy_external/src/cache_manager.cc index 5aa39cb2f4..00bb1e4a1c 100644 --- a/src/components/policy/policy_external/src/cache_manager.cc +++ b/src/components/policy/policy_external/src/cache_manager.cc @@ -41,6 +41,7 @@ #include <vector> #include "utils/file_system.h" +#include "utils/helpers.h" #include "json/reader.h" #include "json/features.h" #include "json/writer.h" @@ -638,13 +639,11 @@ void CacheManager::RemoveAppConsentForGroup(const std::string& app_id, } } -using rpc::policy_table_interface_base::RequestTypes; -using rpc::policy_table_interface_base::RequestType; - void CacheManager::ProcessUpdate( const policy_table::ApplicationPolicies::const_iterator initial_policy_iter) { using namespace policy; + using rpc::policy_table_interface_base::RequestTypes; const RequestTypes& new_request_types = *(initial_policy_iter->second.RequestType); @@ -2392,6 +2391,32 @@ bool CacheManager::ResetPT(const std::string& file_name) { return result; } +policy::RequestType::State CacheManager::GetAppRequestTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); + policy_table::ApplicationPolicies::const_iterator app_policies_iter = + pt_->policy_table.app_policies_section.apps.find(policy_app_id); + if (pt_->policy_table.app_policies_section.apps.end() == app_policies_iter) { + LOG4CXX_DEBUG(logger_, + "Can't find request types for app_id " << policy_app_id); + return policy::RequestType::State::UNAVAILABLE; + } + const policy_table::RequestTypes& request_types = + *app_policies_iter->second.RequestType; + if (!request_types.is_initialized()) { + LOG4CXX_TRACE(logger_, + "Request types for " << policy_app_id << " are OMITTED"); + return RequestType::State::OMITTED; + } + if (request_types.empty()) { + LOG4CXX_TRACE(logger_, + "Request types for " << policy_app_id << " are EMPTY"); + return policy::RequestType::State::EMPTY; + } + return policy::RequestType::State::AVAILABLE; +} + void CacheManager::GetAppRequestTypes( const std::string& policy_app_id, std::vector<std::string>& request_types) const { @@ -2411,16 +2436,64 @@ void CacheManager::GetAppRequestTypes( return; } if (policy_iter->second.RequestType.is_initialized()) { - policy_table::RequestTypes::iterator it_request_type = - policy_iter->second.RequestType->begin(); - for (; it_request_type != policy_iter->second.RequestType->end(); - ++it_request_type) { - request_types.push_back(EnumToJsonString(*it_request_type)); + for (const auto& request_type : *policy_iter->second.RequestType) { + request_types.push_back(EnumToJsonString(request_type)); } } return; } +RequestSubType::State CacheManager::GetAppRequestSubTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); + policy_table::ApplicationPolicies::const_iterator app_policies_iter = + pt_->policy_table.app_policies_section.apps.find(policy_app_id); + if (pt_->policy_table.app_policies_section.apps.end() == app_policies_iter) { + LOG4CXX_DEBUG(logger_, + "Can't find request subtypes for app_id " << policy_app_id); + return RequestSubType::State::UNAVAILABLE; + } + const policy_table::RequestSubTypes& request_subtypes = + *app_policies_iter->second.RequestSubType; + if (!request_subtypes.is_initialized()) { + LOG4CXX_TRACE(logger_, + "Request subtypes for " << policy_app_id << " are OMITTED"); + return RequestSubType::State::OMITTED; + } + if (request_subtypes.empty()) { + LOG4CXX_TRACE(logger_, + "Request subtypes for " << policy_app_id << " are EMPTY"); + return RequestSubType::State::EMPTY; + } + return RequestSubType::State::AVAILABLE; +} + +void CacheManager::GetAppRequestSubTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_subtypes) const { + LOG4CXX_AUTO_TRACE(logger_); + CACHE_MANAGER_CHECK_VOID(); + if (kDeviceId == policy_app_id) { + LOG4CXX_DEBUG(logger_, + "Request subtypes not applicable for app_id " << kDeviceId); + return; + } + sync_primitives::AutoLock auto_lock(cache_lock_); + policy_table::ApplicationPolicies::iterator policy_iter = + pt_->policy_table.app_policies_section.apps.find(policy_app_id); + if (pt_->policy_table.app_policies_section.apps.end() == policy_iter) { + LOG4CXX_DEBUG(logger_, + "Can't find request subtypes for app_id " << policy_app_id); + return; + } + + for (const auto& request_subtype : *policy_iter->second.RequestSubType) { + request_subtypes.push_back(request_subtype); + } + return; +} + const MetaInfo CacheManager::GetMetaInfo() const { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock auto_lock(cache_lock_); diff --git a/src/components/policy/policy_external/src/policy_helper.cc b/src/components/policy/policy_external/src/policy_helper.cc index 8be0372c03..39b9399c24 100644 --- a/src/components/policy/policy_external/src/policy_helper.cc +++ b/src/components/policy/policy_external/src/policy_helper.cc @@ -322,9 +322,21 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { PermissionsCheckResult result = CheckPermissionsChanges(app_policy); - if (!IsPredefinedApp(app_policy) && IsRequestTypeChanged(app_policy)) { - SetPendingPermissions(app_policy, RESULT_REQUEST_TYPE_CHANGED); - AddResult(app_id, RESULT_REQUEST_TYPE_CHANGED); + if (!IsPredefinedApp(app_policy)) { + const bool is_request_type_changed = IsRequestTypeChanged(app_policy); + const bool is_request_subtype_changed = IsRequestSubTypeChanged(app_policy); + if (is_request_type_changed) { + LOG4CXX_TRACE(logger_, + "Request types were changed for application: " << app_id); + SetPendingPermissions(app_policy, RESULT_REQUEST_TYPE_CHANGED); + AddResult(app_id, RESULT_REQUEST_TYPE_CHANGED); + } + if (is_request_subtype_changed) { + LOG4CXX_TRACE( + logger_, "Request subtypes were changed for application: " << app_id); + SetPendingPermissions(app_policy, RESULT_REQUEST_SUBTYPE_CHANGED); + AddResult(app_id, RESULT_REQUEST_SUBTYPE_CHANGED); + } } if (RESULT_NO_CHANGES == result) { @@ -389,17 +401,18 @@ void policy::CheckAppPolicy::SetPendingPermissions( break; case RESULT_REQUEST_TYPE_CHANGED: permissions_diff.requestTypeChanged = true; - { - // Getting RequestTypes from PTU (not from cache) - policy_table::RequestTypes::const_iterator it_request_type = - app_policy.second.RequestType->begin(); - for (; app_policy.second.RequestType->end() != it_request_type; - ++it_request_type) { - permissions_diff.requestType.push_back( - EnumToJsonString(*it_request_type)); - } - } + // Getting Request Types from PTU (not from cache) + for (const auto& request_type : *app_policy.second.RequestType) { + permissions_diff.requestType.push_back(EnumToJsonString(request_type)); + } + break; + case RESULT_REQUEST_SUBTYPE_CHANGED: + permissions_diff.requestSubTypeChanged = true; + // Getting Request SubTypes from PTU (not from cache) + for (const auto& request_subtype : *app_policy.second.RequestSubType) { + permissions_diff.requestSubType.push_back(request_subtype); + } break; default: return; @@ -484,6 +497,32 @@ bool CheckAppPolicy::IsRequestTypeChanged( return diff.size(); } +bool CheckAppPolicy::IsRequestSubTypeChanged( + const AppPoliciesValueType& app_policy) const { + policy::AppPoliciesConstItr it = + snapshot_->policy_table.app_policies_section.apps.find(app_policy.first); + + if (it == snapshot_->policy_table.app_policies_section.apps.end()) { + if (!app_policy.second.RequestSubType->empty()) { + return true; + } + return false; + } + + if (it->second.RequestSubType->size() != + app_policy.second.RequestSubType->size()) { + return true; + } + + policy_table::RequestSubTypes diff; + std::set_difference(it->second.RequestSubType->begin(), + it->second.RequestSubType->end(), + app_policy.second.RequestSubType->begin(), + app_policy.second.RequestSubType->end(), + std::back_inserter(diff)); + return diff.size(); +} + void FillActionsForAppPolicies::operator()( const policy::CheckAppPolicyResults::value_type& value) { const std::string app_id = value.first; @@ -510,6 +549,7 @@ void FillActionsForAppPolicies::operator()( case RESULT_CONSENT_NOT_REQIURED: case RESULT_PERMISSIONS_REVOKED: case RESULT_REQUEST_TYPE_CHANGED: + case RESULT_REQUEST_SUBTYPE_CHANGED: break; case RESULT_NO_CHANGES: default: 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 433a7a6bca..56de26af64 100644 --- a/src/components/policy/policy_external/src/policy_manager_impl.cc +++ b/src/components/policy/policy_external/src/policy_manager_impl.cc @@ -563,6 +563,25 @@ const std::vector<std::string> PolicyManagerImpl::GetAppRequestTypes( return request_types; } +RequestType::State PolicyManagerImpl::GetAppRequestTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + return cache_->GetAppRequestTypesState(policy_app_id); +} + +RequestSubType::State PolicyManagerImpl::GetAppRequestSubTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + return cache_->GetAppRequestSubTypesState(policy_app_id); +} + +const std::vector<std::string> PolicyManagerImpl::GetAppRequestSubTypes( + const std::string& policy_app_id) const { + std::vector<std::string> request_subtypes; + cache_->GetAppRequestSubTypes(policy_app_id, request_subtypes); + return request_subtypes; +} + const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { return cache_->GetVehicleInfo(); } diff --git a/src/components/policy/policy_external/src/policy_table/enums.cc b/src/components/policy/policy_external/src/policy_table/enums.cc index beea68a276..881ae8cbf9 100644 --- a/src/components/policy/policy_external/src/policy_table/enums.cc +++ b/src/components/policy/policy_external/src/policy_table/enums.cc @@ -605,6 +605,10 @@ bool IsValidEnum(RequestType val) { return true; case RT_FOTA: return true; + case RT_OEM_SPECIFIC: + return true; + case RT_EMPTY: + return true; default: return false; } @@ -652,6 +656,10 @@ const char* EnumToJsonString(RequestType val) { return "MEDIA"; case RT_FOTA: return "FOTA"; + case RT_OEM_SPECIFIC: + return "OEM_SPECIFIC"; + case RT_EMPTY: + return "EMPTY"; default: return ""; } @@ -737,6 +745,14 @@ bool EnumFromJsonString(const std::string& literal, RequestType* result) { if ("FOTA" == literal) { *result = RT_FOTA; return true; + } + if ("OEM_SPECIFIC" == literal) { + *result = RT_OEM_SPECIFIC; + return true; + } + if ("EMPTY" == literal) { + *result = RT_EMPTY; + return true; } else { return false; } 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 da83626448..6d0bc9d697 100644 --- a/src/components/policy/policy_external/src/policy_table/types.cc +++ b/src/components/policy/policy_external/src/policy_table/types.cc @@ -238,6 +238,7 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , nicknames(impl::ValueMember(value__, "nicknames")) , AppHMIType(impl::ValueMember(value__, "AppHMIType")) , RequestType(impl::ValueMember(value__, "RequestType")) + , RequestSubType(impl::ValueMember(value__, "RequestSubType")) , memory_kb(impl::ValueMember(value__, "memory_kb"), 0) , heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms")) #ifdef SDL_REMOTE_CONTROL @@ -251,6 +252,7 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("nicknames", nicknames, &result__); impl::WriteJsonField("AppHMIType", AppHMIType, &result__); impl::WriteJsonField("RequestType", RequestType, &result__); + impl::WriteJsonField("RequestSubType", RequestSubType, &result__); impl::WriteJsonField("memory_kb", memory_kb, &result__); impl::WriteJsonField( "heart_beat_timeout_ms", heart_beat_timeout_ms, &result__); @@ -303,6 +305,9 @@ bool ApplicationParams::struct_empty() const { if (RequestType.is_initialized()) { return false; } + if (RequestSubType.is_initialized()) { + return false; + } if (memory_kb.is_initialized()) { return false; } @@ -337,6 +342,9 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { if (!RequestType.is_valid()) { RequestType.ReportErrors(&report__->ReportSubobject("RequestType")); } + if (!RequestSubType.is_valid()) { + RequestSubType.ReportErrors(&report__->ReportSubobject("RequestSubType")); + } if (!priority.is_valid()) { priority.ReportErrors(&report__->ReportSubobject("priority")); } @@ -368,6 +376,7 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { PolicyBase::SetPolicyTableType(pt_type); AppHMIType.SetPolicyTableType(pt_type); RequestType.SetPolicyTableType(pt_type); + RequestSubType.SetPolicyTableType(pt_type); memory_kb.SetPolicyTableType(pt_type); heart_beat_timeout_ms.SetPolicyTableType(pt_type); #ifdef SDL_REMOTE_CONTROL diff --git a/src/components/policy/policy_external/src/policy_table/validation.cc b/src/components/policy/policy_external/src/policy_table/validation.cc index 48a8578855..6936948c84 100644 --- a/src/components/policy/policy_external/src/policy_table/validation.cc +++ b/src/components/policy/policy_external/src/policy_table/validation.cc @@ -89,6 +89,7 @@ bool ApplicationPoliciesSection::Validate() const { continue; } + LOG4CXX_TRACE(logger_, "Checking app Request Types..."); RequestTypes& app_request_types = *iter->second.RequestType; if (app_request_types.is_omitted()) { @@ -133,6 +134,33 @@ bool ApplicationPoliciesSection::Validate() const { ++iter; } + LOG4CXX_TRACE(logger_, "Checking app Request SubTypes..."); + iter = apps.begin(); + while (iter != end_iter) { + if (it_default_policy == iter || it_pre_data_policy == iter) { + ++iter; + continue; + } + ApplicationParams& app_params = (*iter).second; + const bool is_request_subtype_omitted = + !app_params.RequestSubType.is_initialized(); + + if (is_request_subtype_omitted) { + LOG4CXX_WARN(logger_, + "App policy RequestSubTypes omitted." + " Will be replaced with default."); + app_params.RequestSubType = apps[kDefaultApp].RequestSubType; + ++iter; + continue; + } + + const bool is_request_subtype_empty = app_params.RequestSubType->empty(); + if (is_request_subtype_empty) { + LOG4CXX_WARN(logger_, "App policy RequestSubTypes empty."); + } + ++iter; + } + return true; } 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 f58a7f0b82..5bb602244e 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 @@ -670,6 +670,11 @@ bool SQLPTExtRepresentation::SaveApplicationPoliciesSection( return false; } + if (!query_delete.Exec(sql_pt::kDeleteRequestSubType)) { + LOG4CXX_WARN(logger_, "Incorrect delete from request subtype."); + return false; + } + // First, all predefined apps (e.g. default, pre_DataConsent) should be saved, // otherwise another app with the predefined permissions can get incorrect // permissions @@ -713,18 +718,17 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( if (!SetDefaultPolicy(app.first)) { return false; } - if (!SaveRequestType(app.first, *app.second.RequestType)) { - return false; - } } else if (kPreDataConsentId.compare(app.second.get_string()) == 0) { if (!SetPredataPolicy(app.first)) { return false; } - if (!SaveRequestType(app.first, *app.second.RequestType)) { - return false; - } } - + if (!SaveRequestType(app.first, *app.second.RequestType)) { + return false; + } + if (!SaveRequestSubType(app.first, *app.second.RequestSubType)) { + return false; + } // Stop saving other params, since predefined permissions already set return true; } @@ -771,6 +775,10 @@ bool SQLPTExtRepresentation::SaveSpecificAppPolicy( return false; } + if (!SaveRequestSubType(app.first, *app.second.RequestSubType)) { + return false; + } + return true; } 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 9702c315b0..ee53eb1487 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -271,13 +271,21 @@ const std::string kCreateSchema = " REFERENCES `application`(`id`) " "); " "CREATE TABLE IF NOT EXISTS `request_type`( " - " `request_type` VARCHAR(50) NOT NULL, " + " `request_type` VARCHAR(50), " " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, " " PRIMARY KEY(`request_type`,`application_id`), " " CONSTRAINT `fk_app_type_application1` " " FOREIGN KEY(`application_id`) " " REFERENCES `application`(`id`) " "); " + "CREATE TABLE IF NOT EXISTS `request_subtype`( " + " `request_subtype` VARCHAR(50), " + " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, " + " PRIMARY KEY(`request_subtype`,`application_id`), " + " CONSTRAINT `fk_request_subtype_app_id` " + " FOREIGN KEY(`application_id`) " + " REFERENCES `application`(`id`) " + "); " "CREATE INDEX IF NOT EXISTS `app_type.fk_app_type_application1_idx` " " ON `app_type`(`application_id` COLLATE NOCASE); " "CREATE TABLE IF NOT EXISTS `consent_group`( " @@ -482,6 +490,7 @@ const std::string kDropSchema = "DROP INDEX IF EXISTS `app_type.fk_app_type_application1_idx`; " "DROP TABLE IF EXISTS `app_type`; " "DROP TABLE IF EXISTS `request_type`; " + "DROP TABLE IF EXISTS `request_subtype`; " "DROP INDEX IF EXISTS `nickname.fk_nickname_application1_idx`; " "DROP TABLE IF EXISTS `nickname`; " "DROP INDEX IF EXISTS `app_level.fk_app_level_language2_idx`; " @@ -636,6 +645,19 @@ const std::string kInsertRequestType = "INSERT OR IGNORE INTO `request_type` (`application_id`, `request_type`) " "VALUES (?, ?)"; +const std::string kInsertOmittedRequestType = + "INSERT INTO `request_type` (`application_id`) " + "VALUES (?)"; + +const std::string kInsertRequestSubType = + "INSERT INTO `request_subtype` (`application_id`, " + "`request_subtype`) " + "VALUES (?, ?)"; + +const std::string kInsertOmittedRequestSubType = + "INSERT INTO `request_subtype` (`application_id`) " + "VALUES (?)"; + const std::string kUpdateVersion = "UPDATE `version` SET `number`= ?"; const std::string kInsertMessageType = @@ -760,6 +782,11 @@ const std::string kSelectRequestTypes = "SELECT DISTINCT `request_type` FROM `request_type` WHERE `application_id` " "= ?"; +const std::string kSelectRequestSubTypes = + "SELECT DISTINCT `request_subtype` FROM `request_subtype` WHERE " + "`application_id` " + "= ?"; + const std::string kSelectSecondsBetweenRetries = "SELECT `value` FROM `seconds_between_retry` ORDER BY `index`"; @@ -805,6 +832,8 @@ const std::string kDeleteApplication = "DELETE FROM `application`"; const std::string kDeleteRequestType = "DELETE FROM `request_type`"; +const std::string kDeleteRequestSubType = "DELETE FROM `request_subtype`"; + const std::string kSelectApplicationRevoked = "SELECT `is_revoked` FROM `application` WHERE `id` = ?"; diff --git a/src/components/policy/policy_external/src/sql_pt_representation.cc b/src/components/policy/policy_external/src/sql_pt_representation.cc index 4315d99b3a..b05716dc3f 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -786,6 +786,9 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( if (!GatherRequestType(app_id, &*params.RequestType)) { return false; } + if (!GatherRequestSubType(app_id, &*params.RequestSubType)) { + return false; + } (*policies).apps[app_id] = params; } @@ -1175,15 +1178,83 @@ bool SQLPTRepresentation::SaveRequestType( } policy_table::RequestTypes::const_iterator it; - for (it = types.begin(); it != types.end(); ++it) { + if (!types.empty()) { + LOG4CXX_WARN(logger_, "Request types not empty."); + for (it = types.begin(); it != types.end(); ++it) { + query.Bind(0, app_id); + query.Bind(1, std::string(policy_table::EnumToJsonString(*it))); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request types."); + return false; + } + } + } else if (types.is_initialized()) { + LOG4CXX_WARN(logger_, "Request types empty."); query.Bind(0, app_id); - query.Bind(1, std::string(policy_table::EnumToJsonString(*it))); + query.Bind(1, + std::string(policy_table::EnumToJsonString( + policy_table::RequestType::RT_EMPTY))); if (!query.Exec() || !query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into request types."); return false; } + } else { + utils::dbms::SQLQuery query_omitted(db()); + if (!query_omitted.Prepare(sql_pt::kInsertOmittedRequestType)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for request types."); + return false; + } + LOG4CXX_WARN(logger_, "Request types omitted."); + query_omitted.Bind(0, app_id); + if (!query_omitted.Exec() || !query_omitted.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request types."); + return false; + } + } + return true; +} + +bool SQLPTRepresentation::SaveRequestSubType( + const std::string& app_id, + const policy_table::RequestSubTypes& request_subtypes) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertRequestSubType)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for request subtypes."); + return false; } + policy_table::Strings::const_iterator it; + if (!request_subtypes.empty()) { + LOG4CXX_TRACE(logger_, "Request subtypes are not empty."); + for (it = request_subtypes.begin(); it != request_subtypes.end(); ++it) { + query.Bind(0, app_id); + query.Bind(1, *it); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); + return false; + } + } + } else if (request_subtypes.is_initialized()) { + LOG4CXX_WARN(logger_, "Request subtypes empty."); + query.Bind(0, app_id); + query.Bind(1, std::string("EMPTY")); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); + return false; + } + } else { + utils::dbms::SQLQuery query_omitted(db()); + if (!query_omitted.Prepare(sql_pt::kInsertOmittedRequestSubType)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for request subtypes."); + return false; + } + LOG4CXX_WARN(logger_, "Request subtypes omitted."); + query_omitted.Bind(0, app_id); + if (!query_omitted.Exec() || !query_omitted.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); + return false; + } + } return true; } @@ -1583,11 +1654,36 @@ bool SQLPTRepresentation::GatherRequestType( if (!policy_table::EnumFromJsonString(query.GetString(0), &type)) { return false; } + if (policy_table::RequestType::RT_EMPTY == type) { + request_types->mark_initialized(); + continue; + } request_types->push_back(type); } return true; } +bool SQLPTRepresentation::GatherRequestSubType( + const std::string& app_id, + policy_table::RequestSubTypes* request_subtypes) const { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectRequestSubTypes)) { + LOG4CXX_WARN(logger_, "Incorrect select from request subtypes."); + return false; + } + + query.Bind(0, app_id); + while (query.Next()) { + const std::string request_subtype = query.GetString(0); + if ("EMPTY" == request_subtype) { + request_subtypes->mark_initialized(); + continue; + } + request_subtypes->push_back(request_subtype); + } + return true; +} + bool SQLPTRepresentation::GatherNickName( const std::string& app_id, policy_table::Strings* nicknames) const { utils::dbms::SQLQuery query(db()); @@ -1907,6 +2003,13 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) { !SaveRequestType(app_id, request_types)) { return false; } + + policy_table::Strings request_subtypes; + if (!GatherRequestSubType(kDefaultId, &request_subtypes) || + !SaveRequestSubType(app_id, request_subtypes)) { + return false; + } + policy_table::AppHMITypes app_types; if (!GatherAppType(kDefaultId, &app_types) || !SaveAppType(app_id, app_types)) { diff --git a/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json b/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json index c5386f612e..ced0a9d603 100644 --- a/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json +++ b/src/components/policy/policy_external/test/json/sdl_preloaded_pt.json @@ -20,6 +20,7 @@ "notifications_per_minute_by_priority": { "EMERGENCY": 60, "NAVIGATION": 15, + "PROJECTION": 15, "COMMUNICATION": 6, "NORMAL": 4, "NONE": 0 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 a657a01145..0b0831eaad 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 @@ -407,7 +407,8 @@ TEST_F(SQLPTRepresentationTest, query.Prepare(query_select); query.Next(); - const int policy_tables_number = 32; + // 33 - is current total tables number created by schema + const int policy_tables_number = 33; ASSERT_EQ(policy_tables_number, query.GetInteger(0)); const std::string query_select_count_of_iap_buffer_full = 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 8c0acd44d2..4a0a09db83 100644 --- a/src/components/policy/policy_regular/include/policy/cache_manager.h +++ b/src/components/policy/policy_regular/include/policy/cache_manager.h @@ -73,6 +73,22 @@ class CacheManager : public CacheManagerInterface { CheckPermissionResult& result); /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Returns true if Policy Table was not updated yet * from preloaded pt file. */ @@ -597,8 +613,18 @@ class CacheManager : public CacheManagerInterface { * @param policy_app_id Unique application id * @param request_types Request types of application */ - void GetAppRequestTypes(const std::string& policy_app_id, - std::vector<std::string>& request_types) const; + void GetAppRequestTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_types) const OVERRIDE; + + /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @param request_subtypes Request subtypes of application to be filled + */ + void GetAppRequestSubTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_subtypes) const OVERRIDE; /** * @brief GetCertificate allows to obtain certificate in order to 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 9f7c7318db..3dd2953865 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 @@ -46,6 +46,16 @@ namespace policy_table = rpc::policy_table_interface_base; namespace policy { +namespace RequestType { +// Describes available RequestType states in policy table +enum class State { UNAVAILABLE = 0, AVAILABLE, EMPTY, OMITTED }; +} // namespace RequestType + +namespace RequestSubType { +// Describes available RequestSubType states in policy table +enum class State { UNAVAILABLE = 0, AVAILABLE, EMPTY, OMITTED }; +} // namespace RequestSubType + class CacheManagerInterface { public: virtual ~CacheManagerInterface() {} @@ -67,6 +77,22 @@ class CacheManagerInterface { CheckPermissionResult& result) = 0; /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + virtual RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const = 0; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + virtual RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const = 0; + + /** * @brief Returns true if Policy Table was not updated yet * from preloaded pt file. */ @@ -627,6 +653,15 @@ class CacheManagerInterface { std::vector<std::string>& request_types) const = 0; /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @param request_subtypes Request subtypes of application to be filled + */ + virtual void GetAppRequestSubTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_subtypes) const = 0; + + /** * @brief GetCertificate allows to obtain certificate in order to * make secure connection * diff --git a/src/components/policy/policy_regular/include/policy/policy_helper.h b/src/components/policy/policy_regular/include/policy/policy_helper.h index 8a60801dd4..7f27ab2676 100644 --- a/src/components/policy/policy_regular/include/policy/policy_helper.h +++ b/src/components/policy/policy_regular/include/policy/policy_helper.h @@ -95,7 +95,8 @@ struct CheckAppPolicy { RESULT_CONSENT_NEEDED, RESULT_CONSENT_NOT_REQIURED, RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED, - RESULT_REQUEST_TYPE_CHANGED + RESULT_REQUEST_TYPE_CHANGED, + RESULT_REQUEST_SUBTYPE_CHANGED }; void SetPendingPermissions(const AppPoliciesValueType& app_policy, @@ -126,6 +127,7 @@ struct CheckAppPolicy { bool IsConsentRequired(const std::string& app_id, const std::string& group_name) const; bool IsRequestTypeChanged(const AppPoliciesValueType& app_policy) const; + bool IsRequestSubTypeChanged(const AppPoliciesValueType& app_policy) const; private: PolicyManagerImpl* pm_; 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 941db1a67f..8379cf4d82 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 @@ -532,6 +532,22 @@ class PolicyManagerImpl : public PolicyManager { void OnAppsSearchCompleted(const bool trigger_ptu) OVERRIDE; /** + * @brief Get state of request types for given application + * @param policy_app_id Unique application id + * @return request type state + */ + RequestType::State GetAppRequestTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** + * @brief Get state of request subtypes for given application + * @param policy_app_id Unique application id + * @return request subtype state + */ + RequestSubType::State GetAppRequestSubTypesState( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Gets request types for application * @param policy_app_id Unique application id * @return request types of application @@ -540,6 +556,14 @@ class PolicyManagerImpl : public PolicyManager { const std::string policy_app_id) const OVERRIDE; /** + * @brief Gets request subtypes for application + * @param policy_app_id Unique application id + * @return request subtypes of application + */ + const std::vector<std::string> GetAppRequestSubTypes( + const std::string& policy_app_id) const OVERRIDE; + + /** * @brief Get information about vehicle * @return vehicle information */ diff --git a/src/components/policy/policy_regular/include/policy/policy_table/enums.h b/src/components/policy/policy_regular/include/policy/policy_table/enums.h index bd3319dba6..dbe00d0f9c 100644 --- a/src/components/policy/policy_regular/include/policy/policy_table/enums.h +++ b/src/components/policy/policy_regular/include/policy/policy_table/enums.h @@ -134,7 +134,9 @@ enum RequestType { RT_VEHICLE_DIAGNOSTICS, RT_EMERGENCY, RT_MEDIA, - RT_FOTA + RT_FOTA, + RT_OEM_SPECIFIC, + RT_EMPTY // Added to allow empty Request Types handling }; bool IsValidEnum(RequestType val); 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 61585776f2..8197247907 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 @@ -76,7 +76,7 @@ typedef Map<URL, 1, 255> URLList; typedef Map<URLList, 1, 255> ServiceEndpoints; typedef uint8_t NumberOfNotificationsType; -typedef Map<Integer<NumberOfNotificationsType, 0, 255>, 0, 6> +typedef Map<Integer<NumberOfNotificationsType, 0, 255>, 0, 7> NumberOfNotificationsPerMinute; typedef Array<Integer<uint16_t, 1, 1000>, 0, 5> SecondsBetweenRetries; @@ -96,6 +96,8 @@ typedef Map<DeviceParams, 0, 255> DeviceData; typedef Array<Enum<RequestType>, 0, 255> RequestTypes; +typedef Strings RequestSubTypes; + #ifdef SDL_REMOTE_CONTROL typedef Map<Strings, 0, 255> RemoteRpcs; typedef Map<RemoteRpcs, 0, 255> AccessModules; @@ -139,6 +141,7 @@ struct ApplicationParams : PolicyBase { Optional<Strings> nicknames; Optional<AppHMITypes> AppHMIType; Optional<RequestTypes> RequestType; + Optional<RequestSubTypes> RequestSubType; Optional<Integer<uint16_t, 0, 65225> > memory_kb; Optional<Integer<uint32_t, 0, UINT_MAX> > heart_beat_timeout_ms; Optional<String<0, 255> > certificate; 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 af1d119e7a..e0fc808e2f 100644 --- a/src/components/policy/policy_regular/include/policy/policy_types.h +++ b/src/components/policy/policy_regular/include/policy/policy_types.h @@ -267,7 +267,8 @@ struct AppPermissions { , appRevoked(false) , appPermissionsConsentNeeded(false) , appUnauthorized(false) - , requestTypeChanged(false) {} + , requestTypeChanged(false) + , requestSubTypeChanged(false) {} std::string application_id; bool isAppPermissionsRevoked; @@ -280,6 +281,8 @@ struct AppPermissions { DeviceParams deviceInfo; bool requestTypeChanged; std::vector<std::string> requestType; + bool requestSubTypeChanged; + std::vector<std::string> requestSubType; }; /** @@ -471,7 +474,8 @@ enum PermissionsCheckResult { RESULT_CONSENT_NEEDED, RESULT_CONSENT_NOT_REQIURED, RESULT_PERMISSIONS_REVOKED_AND_CONSENT_NEEDED, - RESULT_REQUEST_TYPE_CHANGED + RESULT_REQUEST_TYPE_CHANGED, + RESULT_REQUEST_SUBTYPE_CHANGED }; /** 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 2ded25e456..5259ffa7e9 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 @@ -65,6 +65,7 @@ extern const std::string kSelectAppGroups; extern const std::string kSelectNicknames; extern const std::string kSelectAppTypes; extern const std::string kSelectRequestTypes; +extern const std::string kSelectRequestSubTypes; extern const std::string kSelectSecondsBetweenRetries; extern const std::string kSelectIgnitionCycles; extern const std::string kSelectKilometers; @@ -78,6 +79,9 @@ extern const std::string kInsertAppGroup; extern const std::string kInsertNickname; extern const std::string kInsertAppType; extern const std::string kInsertRequestType; +extern const std::string kInsertOmittedRequestType; +extern const std::string kInsertOmittedRequestSubType; +extern const std::string kInsertRequestSubType; extern const std::string kInsertMessageType; extern const std::string kInsertLanguage; extern const std::string kInsertMessageString; @@ -97,6 +101,7 @@ extern const std::string kDeleteRpc; extern const std::string kDeleteAppGroup; extern const std::string kDeleteApplication; extern const std::string kDeleteRequestType; +extern const std::string kDeleteRequestSubType; extern const std::string kDeleteDevice; extern const std::string kIncrementIgnitionCycles; extern const std::string kResetIgnitionCycles; 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 6b5d6111f1..e39e0d5873 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 @@ -132,6 +132,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { policy_table::AppHMITypes* app_types) const; bool GatherRequestType(const std::string& app_id, policy_table::RequestTypes* request_types) const; + bool GatherRequestSubType( + const std::string& app_id, + policy_table::RequestSubTypes* request_subtypes) const; bool GatherNickName(const std::string& app_id, policy_table::Strings* nicknames) const; @@ -167,6 +170,9 @@ class SQLPTRepresentation : public virtual PTRepresentation { const policy_table::AppHMITypes& types); bool SaveRequestType(const std::string& app_id, const policy_table::RequestTypes& types); + bool SaveRequestSubType( + const std::string& app_id, + const policy_table::RequestSubTypes& request_subtypes); public: bool UpdateRequired() const; diff --git a/src/components/policy/policy_regular/policy_table_interface_ext.xml b/src/components/policy/policy_regular/policy_table_interface_ext.xml index 4f87a9e254..93edce3e3a 100644 --- a/src/components/policy/policy_regular/policy_table_interface_ext.xml +++ b/src/components/policy/policy_regular/policy_table_interface_ext.xml @@ -126,7 +126,7 @@ minsize="1" maxsize="255" /> <typedef name="NumberOfNotificationsPerMinute" type="Integer" - map="true" maxsize="6" minvalue="0" maxvalue="255" /> + map="true" maxsize="7" minvalue="0" maxvalue="255" /> <typedef name="SecondsBetweenRetries" type="Integer" array="true" maxsize="10" minvalue="1" maxvalue="1000" /> diff --git a/src/components/policy/policy_regular/src/cache_manager.cc b/src/components/policy/policy_regular/src/cache_manager.cc index 6a142374d5..1d51b81af4 100644 --- a/src/components/policy/policy_regular/src/cache_manager.cc +++ b/src/components/policy/policy_regular/src/cache_manager.cc @@ -39,6 +39,7 @@ #include <sstream> #include "utils/file_system.h" +#include "utils/helpers.h" #include "json/reader.h" #include "json/features.h" #include "json/writer.h" @@ -1550,6 +1551,32 @@ int32_t CacheManager::GenerateHash(const std::string& str_to_hash) { return result; } +RequestType::State CacheManager::GetAppRequestTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); + policy_table::ApplicationPolicies::iterator app_policies_iter = + pt_->policy_table.app_policies_section.apps.find(policy_app_id); + if (pt_->policy_table.app_policies_section.apps.end() == app_policies_iter) { + LOG4CXX_DEBUG(logger_, + "Can't find request types for app_id " << policy_app_id); + return RequestType::State::UNAVAILABLE; + } + const policy_table::RequestTypes& request_types = + *app_policies_iter->second.RequestType; + if (!request_types.is_initialized()) { + LOG4CXX_DEBUG(logger_, + "Request types for " << policy_app_id << " are OMITTED"); + return RequestType::State::OMITTED; + } + if (request_types.empty()) { + LOG4CXX_DEBUG(logger_, + "Request types for " << policy_app_id << " are EMPTY"); + return RequestType::State::EMPTY; + } + return RequestType::State::AVAILABLE; +} + void CacheManager::GetAppRequestTypes( const std::string& policy_app_id, std::vector<std::string>& request_types) const { @@ -1568,11 +1595,60 @@ void CacheManager::GetAppRequestTypes( "Can't find request types for app_id " << policy_app_id); return; } - policy_table::RequestTypes::iterator it_request_type = - policy_iter->second.RequestType->begin(); - for (; it_request_type != policy_iter->second.RequestType->end(); - ++it_request_type) { - request_types.push_back(EnumToJsonString(*it_request_type)); + + for (const auto& request_type : *policy_iter->second.RequestType) { + request_types.push_back(EnumToJsonString(request_type)); + } + return; +} + +RequestSubType::State CacheManager::GetAppRequestSubTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock auto_lock(cache_lock_); + policy_table::ApplicationPolicies::iterator app_policies_iter = + pt_->policy_table.app_policies_section.apps.find(policy_app_id); + if (pt_->policy_table.app_policies_section.apps.end() == app_policies_iter) { + LOG4CXX_DEBUG(logger_, + "Can't find request subtypes for app_id " << policy_app_id); + return RequestSubType::State::UNAVAILABLE; + } + const policy_table::RequestSubTypes& request_subtypes = + *app_policies_iter->second.RequestSubType; + if (!request_subtypes.is_initialized()) { + LOG4CXX_DEBUG(logger_, + "Request subtypes for " << policy_app_id << " are OMITTED"); + return RequestSubType::State::OMITTED; + } + if (request_subtypes.empty()) { + LOG4CXX_DEBUG(logger_, + "Request subtypes for " << policy_app_id << " are EMPTY"); + return RequestSubType::State::EMPTY; + } + return RequestSubType::State::AVAILABLE; +} + +void CacheManager::GetAppRequestSubTypes( + const std::string& policy_app_id, + std::vector<std::string>& request_types) const { + LOG4CXX_AUTO_TRACE(logger_); + CACHE_MANAGER_CHECK_VOID(); + sync_primitives::AutoLock auto_lock(cache_lock_); + if (kDeviceId == policy_app_id) { + LOG4CXX_DEBUG(logger_, + "Request subtypes not applicable for app_id " << kDeviceId); + return; + } + policy_table::ApplicationPolicies::iterator policy_iter = + pt_->policy_table.app_policies_section.apps.find(policy_app_id); + if (pt_->policy_table.app_policies_section.apps.end() == policy_iter) { + LOG4CXX_DEBUG(logger_, + "Can't find request subtypes for app_id " << policy_app_id); + return; + } + + for (const auto& request_subtype : *policy_iter->second.RequestSubType) { + request_types.push_back(request_subtype); } return; } diff --git a/src/components/policy/policy_regular/src/policy_helper.cc b/src/components/policy/policy_regular/src/policy_helper.cc index 95f275769c..796dd25ec4 100644 --- a/src/components/policy/policy_regular/src/policy_helper.cc +++ b/src/components/policy/policy_regular/src/policy_helper.cc @@ -339,9 +339,20 @@ bool CheckAppPolicy::operator()(const AppPoliciesValueType& app_policy) { } PermissionsCheckResult result = CheckPermissionsChanges(app_policy); - if (!IsPredefinedApp(app_policy) && IsRequestTypeChanged(app_policy)) { - SetPendingPermissions(app_policy, RESULT_REQUEST_TYPE_CHANGED); - NotifySystem(app_policy); + if (!IsPredefinedApp(app_policy)) { + const bool is_request_type_changed = IsRequestTypeChanged(app_policy); + const bool is_request_subtype_changed = IsRequestSubTypeChanged(app_policy); + + if (is_request_type_changed) { + SetPendingPermissions(app_policy, RESULT_REQUEST_TYPE_CHANGED); + } + if (is_request_subtype_changed) { + SetPendingPermissions(app_policy, RESULT_REQUEST_SUBTYPE_CHANGED); + } + + if (is_request_type_changed || is_request_subtype_changed) { + NotifySystem(app_policy); + } } if (RESULT_NO_CHANGES == result) { LOG4CXX_INFO(logger_, @@ -412,17 +423,19 @@ void policy::CheckAppPolicy::SetPendingPermissions( case RESULT_REQUEST_TYPE_CHANGED: permissions_diff.priority.clear(); permissions_diff.requestTypeChanged = true; - { - // Getting RequestTypes from PTU (not from cache) - policy_table::RequestTypes::const_iterator it_request_type = - app_policy.second.RequestType->begin(); - for (; app_policy.second.RequestType->end() != it_request_type; - ++it_request_type) { - permissions_diff.requestType.push_back( - EnumToJsonString(*it_request_type)); - } - } + // Getting Request Types from PTU (not from cache) + for (const auto& request_type : *app_policy.second.RequestType) { + permissions_diff.requestType.push_back(EnumToJsonString(request_type)); + } + break; + case RESULT_REQUEST_SUBTYPE_CHANGED: + permissions_diff.priority.clear(); + permissions_diff.requestSubTypeChanged = true; + // Getting Request SubTypes from PTU (not from cache) + for (const auto& request_subtype : *app_policy.second.RequestSubType) { + permissions_diff.requestSubType.push_back(request_subtype); + } break; default: return; @@ -491,6 +504,32 @@ bool CheckAppPolicy::IsRequestTypeChanged( return diff.size(); } +bool CheckAppPolicy::IsRequestSubTypeChanged( + const AppPoliciesValueType& app_policy) const { + policy::AppPoliciesConstItr it = + snapshot_->policy_table.app_policies_section.apps.find(app_policy.first); + + if (it == snapshot_->policy_table.app_policies_section.apps.end()) { + if (!app_policy.second.RequestSubType->empty()) { + return true; + } + return false; + } + + if (it->second.RequestSubType->size() != + app_policy.second.RequestSubType->size()) { + return true; + } + + policy_table::RequestSubTypes diff; + std::set_difference(it->second.RequestSubType->begin(), + it->second.RequestSubType->end(), + app_policy.second.RequestSubType->begin(), + app_policy.second.RequestSubType->end(), + std::back_inserter(diff)); + return diff.size(); +} + FillNotificationData::FillNotificationData(Permissions& data, GroupConsent group_state, GroupConsent undefined_group_consent) 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 3e08147a4c..a48a9a1ba0 100644 --- a/src/components/policy/policy_regular/src/policy_manager_impl.cc +++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc @@ -385,6 +385,25 @@ const std::vector<std::string> PolicyManagerImpl::GetAppRequestTypes( return request_types; } +RequestType::State PolicyManagerImpl::GetAppRequestTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + return cache_->GetAppRequestTypesState(policy_app_id); +} + +RequestSubType::State PolicyManagerImpl::GetAppRequestSubTypesState( + const std::string& policy_app_id) const { + LOG4CXX_AUTO_TRACE(logger_); + return cache_->GetAppRequestSubTypesState(policy_app_id); +} + +const std::vector<std::string> PolicyManagerImpl::GetAppRequestSubTypes( + const std::string& policy_app_id) const { + std::vector<std::string> request_subtypes; + cache_->GetAppRequestSubTypes(policy_app_id, request_subtypes); + return request_subtypes; +} + const VehicleInfo PolicyManagerImpl::GetVehicleInfo() const { return cache_->GetVehicleInfo(); } diff --git a/src/components/policy/policy_regular/src/policy_table/enums.cc b/src/components/policy/policy_regular/src/policy_table/enums.cc index 2145f06a4b..1dae9c5f96 100644 --- a/src/components/policy/policy_regular/src/policy_table/enums.cc +++ b/src/components/policy/policy_regular/src/policy_table/enums.cc @@ -468,6 +468,10 @@ bool IsValidEnum(RequestType val) { return true; case RT_FOTA: return true; + case RT_OEM_SPECIFIC: + return true; + case RT_EMPTY: + return true; default: return false; } @@ -515,6 +519,10 @@ const char* EnumToJsonString(RequestType val) { return "MEDIA"; case RT_FOTA: return "FOTA"; + case RT_OEM_SPECIFIC: + return "OEM_SPECIFIC"; + case RT_EMPTY: + return "EMPTY"; default: return ""; } @@ -600,6 +608,14 @@ bool EnumFromJsonString(const std::string& literal, RequestType* result) { if ("FOTA" == literal) { *result = RT_FOTA; return true; + } + if ("OEM_SPECIFIC" == literal) { + *result = RT_OEM_SPECIFIC; + return true; + } + if ("EMPTY" == literal) { + *result = RT_EMPTY; + return true; } else { return false; } 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 5f6f85f5dd..c4846c0d40 100644 --- a/src/components/policy/policy_regular/src/policy_table/types.cc +++ b/src/components/policy/policy_regular/src/policy_table/types.cc @@ -164,6 +164,7 @@ ApplicationParams::ApplicationParams(const Json::Value* value__) , nicknames(impl::ValueMember(value__, "nicknames")) , AppHMIType(impl::ValueMember(value__, "AppHMIType")) , RequestType(impl::ValueMember(value__, "RequestType")) + , RequestSubType(impl::ValueMember(value__, "RequestSubType")) , memory_kb(impl::ValueMember(value__, "memory_kb"), 0) , heart_beat_timeout_ms(impl::ValueMember(value__, "heart_beat_timeout_ms")) , certificate(impl::ValueMember(value__, "certificate"), "not_specified") @@ -179,6 +180,7 @@ Json::Value ApplicationParams::ToJsonValue() const { impl::WriteJsonField("nicknames", nicknames, &result__); impl::WriteJsonField("AppHMIType", AppHMIType, &result__); impl::WriteJsonField("RequestType", RequestType, &result__); + impl::WriteJsonField("RequestSubType", RequestSubType, &result__); impl::WriteJsonField("memory_kb", memory_kb, &result__); impl::WriteJsonField( "heart_beat_timeout_ms", heart_beat_timeout_ms, &result__); @@ -189,7 +191,8 @@ Json::Value ApplicationParams::ToJsonValue() const { } bool ApplicationParams::is_valid() const { - // RequestType is not validated since there is high-level validation logic, + // RequestType and RequestSubType are not validated since there is high-level + // validation logic, // which takes into account information not available here. if (!PolicyBase::is_valid()) { return false; @@ -240,6 +243,9 @@ bool ApplicationParams::struct_empty() const { if (RequestType.is_initialized()) { return false; } + if (RequestSubType.is_initialized()) { + return false; + } if (memory_kb.is_initialized()) { return false; } @@ -273,6 +279,9 @@ void ApplicationParams::ReportErrors(rpc::ValidationReport* report__) const { if (!RequestType.is_valid()) { RequestType.ReportErrors(&report__->ReportSubobject("RequestType")); } + if (!RequestSubType.is_valid()) { + RequestSubType.ReportErrors(&report__->ReportSubobject("RequestSubType")); + } if (!priority.is_valid()) { priority.ReportErrors(&report__->ReportSubobject("priority")); } @@ -298,6 +307,7 @@ void ApplicationParams::SetPolicyTableType(PolicyTableType pt_type) { groups.SetPolicyTableType(pt_type); AppHMIType.SetPolicyTableType(pt_type); RequestType.SetPolicyTableType(pt_type); + RequestSubType.SetPolicyTableType(pt_type); memory_kb.SetPolicyTableType(pt_type); heart_beat_timeout_ms.SetPolicyTableType(pt_type); certificate.SetPolicyTableType(pt_type); diff --git a/src/components/policy/policy_regular/src/policy_table/validation.cc b/src/components/policy/policy_regular/src/policy_table/validation.cc index 10b8e4bf7c..e760293ea6 100644 --- a/src/components/policy/policy_regular/src/policy_table/validation.cc +++ b/src/components/policy/policy_regular/src/policy_table/validation.cc @@ -40,11 +40,12 @@ bool ApplicationPoliciesSection::Validate() const { return false; } - PolicyTableType pt_type = GetPolicyTableType(); + const PolicyTableType pt_type = GetPolicyTableType(); if (PT_PRELOADED != pt_type && PT_UPDATE != pt_type) { return true; } + LOG4CXX_TRACE(logger_, "Checking app Request Types..."); if (!it_default_policy->second.RequestType.is_valid()) { LOG4CXX_WARN(logger_, "Default policy RequestTypes are not valid. Will be cleaned."); @@ -65,10 +66,15 @@ bool ApplicationPoliciesSection::Validate() const { ApplicationPolicies::iterator end_iter = apps.end(); while (iter != end_iter) { + if (it_default_policy == iter || it_pre_data_policy == iter) { + ++iter; + continue; + } ApplicationParams& app_params = (*iter).second; - bool is_request_type_omitted = !app_params.RequestType.is_initialized(); - bool is_request_type_valid = app_params.RequestType.is_valid(); - bool is_request_type_empty = app_params.RequestType->empty(); + const bool is_request_type_omitted = + !app_params.RequestType.is_initialized(); + const bool is_request_type_valid = app_params.RequestType.is_valid(); + const bool is_request_type_empty = app_params.RequestType->empty(); if (PT_PRELOADED == pt_type) { if (!is_request_type_valid) { @@ -111,6 +117,33 @@ bool ApplicationPoliciesSection::Validate() const { ++iter; } + LOG4CXX_TRACE(logger_, "Checking app Request SubTypes..."); + iter = apps.begin(); + while (iter != end_iter) { + if (it_default_policy == iter || it_pre_data_policy == iter) { + ++iter; + continue; + } + ApplicationParams& app_params = (*iter).second; + const bool is_request_subtype_omitted = + !app_params.RequestSubType.is_initialized(); + + if (is_request_subtype_omitted) { + LOG4CXX_WARN(logger_, + "App policy RequestSubTypes omitted." + " Will be replaced with default."); + app_params.RequestSubType = apps[kDefaultApp].RequestSubType; + ++iter; + continue; + } + + const bool is_request_subtype_empty = app_params.RequestSubType->empty(); + if (is_request_subtype_empty) { + LOG4CXX_WARN(logger_, "App policy RequestSubTypes empty."); + } + ++iter; + } + return true; } 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 ef4ef49273..91a5573a04 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -258,13 +258,21 @@ const std::string kCreateSchema = " REFERENCES `application`(`id`) " "); " "CREATE TABLE IF NOT EXISTS `request_type`( " - " `request_type` VARCHAR(50) NOT NULL, " + " `request_type` VARCHAR(50), " " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, " " PRIMARY KEY(`request_type`,`application_id`), " " CONSTRAINT `fk_app_type_application1` " " FOREIGN KEY(`application_id`) " " REFERENCES `application`(`id`) " "); " + "CREATE TABLE IF NOT EXISTS `request_subtype`( " + " `request_subtype` VARCHAR(50), " + " `application_id` VARCHAR(45) NOT NULL COLLATE NOCASE, " + " PRIMARY KEY(`request_subtype`,`application_id`), " + " CONSTRAINT `fk_request_subtype_app_id` " + " FOREIGN KEY(`application_id`) " + " REFERENCES `application`(`id`) " + "); " "CREATE INDEX IF NOT EXISTS `app_type.fk_app_type_application1_idx` " " ON `app_type`(`application_id` COLLATE NOCASE); " "CREATE TABLE IF NOT EXISTS `consent_group`( " @@ -440,6 +448,8 @@ const std::string kDropSchema = "DROP TABLE IF EXISTS `consent_group`; " "DROP INDEX IF EXISTS `app_type.fk_app_type_application1_idx`; " "DROP TABLE IF EXISTS `app_type`; " + "DROP TABLE IF EXISTS `request_type`; " + "DROP TABLE IF EXISTS `request_subtype`; " "DROP INDEX IF EXISTS `nickname.fk_nickname_application1_idx`; " "DROP TABLE IF EXISTS `nickname`; " "DROP INDEX IF EXISTS `app_level.fk_app_level_language2_idx`; " @@ -582,9 +592,22 @@ const std::string kInsertAppType = "INSERT OR IGNORE INTO `app_type` (`application_id`, `name`) VALUES (?, ?)"; const std::string kInsertRequestType = - "INSERT OR IGNORE INTO `request_type` (`application_id`, `request_type`) " + "INSERT INTO `request_type` (`application_id`, `request_type`) " "VALUES (?, ?)"; +const std::string kInsertOmittedRequestType = + "INSERT INTO `request_type` (`application_id`) " + "VALUES (?)"; + +const std::string kInsertRequestSubType = + "INSERT INTO `request_subtype` (`application_id`, " + "`request_subtype`) " + "VALUES (?, ?)"; + +const std::string kInsertOmittedRequestSubType = + "INSERT INTO `request_subtype` (`application_id`) " + "VALUES (?)"; + const std::string kUpdateVersion = "UPDATE `version` SET `number`= ?"; const std::string kInsertMessageType = @@ -695,6 +718,11 @@ const std::string kSelectRequestTypes = "SELECT DISTINCT `request_type` FROM `request_type` WHERE `application_id` " "= ?"; +const std::string kSelectRequestSubTypes = + "SELECT DISTINCT `request_subtype` FROM `request_subtype` WHERE " + "`application_id` " + "= ?"; + const std::string kSelectSecondsBetweenRetries = "SELECT `value` FROM `seconds_between_retry` ORDER BY `index`"; @@ -740,6 +768,8 @@ const std::string kDeleteApplication = "DELETE FROM `application`"; const std::string kDeleteRequestType = "DELETE FROM `request_type`"; +const std::string kDeleteRequestSubType = "DELETE FROM `request_subtype`"; + const std::string kSelectApplicationRevoked = "SELECT `is_revoked` FROM `application` WHERE `id` = ?"; 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 9840a08b26..a57230aeb1 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -744,6 +744,10 @@ bool SQLPTRepresentation::GatherApplicationPoliciesSection( return false; } + if (!GatherRequestSubType(app_id, &*params.RequestSubType)) { + return false; + } + (*policies).apps[app_id] = params; } return true; @@ -837,6 +841,7 @@ bool SQLPTRepresentation::SaveFunctionalGroupings( bool SQLPTRepresentation::SaveRpcs(int64_t group_id, const policy_table::Rpc& rpcs) { + LOG4CXX_AUTO_TRACE(logger_); utils::dbms::SQLQuery query(db()); utils::dbms::SQLQuery query_parameter(db()); if (!query.Prepare(sql_pt::kInsertRpc) || @@ -916,6 +921,11 @@ bool SQLPTRepresentation::SaveApplicationPoliciesSection( return false; } + if (!query_delete.Exec(sql_pt::kDeleteRequestSubType)) { + LOG4CXX_WARN(logger_, "Incorrect delete from request subtype."); + return false; + } + // All predefined apps (e.g. default, pre_DataConsent) should be saved first, // otherwise another app with the predefined permissions can get incorrect // permissions @@ -1006,6 +1016,10 @@ bool SQLPTRepresentation::SaveSpecificAppPolicy( return false; } + if (!SaveRequestSubType(app.first, *app.second.RequestSubType)) { + return false; + } + return true; } @@ -1109,15 +1123,83 @@ bool SQLPTRepresentation::SaveRequestType( } policy_table::RequestTypes::const_iterator it; - for (it = types.begin(); it != types.end(); ++it) { + if (!types.empty()) { + LOG4CXX_WARN(logger_, "Request types not empty."); + for (it = types.begin(); it != types.end(); ++it) { + query.Bind(0, app_id); + query.Bind(1, std::string(policy_table::EnumToJsonString(*it))); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request types."); + return false; + } + } + } else if (types.is_initialized()) { + LOG4CXX_WARN(logger_, "Request types empty."); query.Bind(0, app_id); - query.Bind(1, std::string(policy_table::EnumToJsonString(*it))); + query.Bind(1, + std::string(policy_table::EnumToJsonString( + policy_table::RequestType::RT_EMPTY))); if (!query.Exec() || !query.Reset()) { LOG4CXX_WARN(logger_, "Incorrect insert into request types."); return false; } + } else { + utils::dbms::SQLQuery query_omitted(db()); + if (!query_omitted.Prepare(sql_pt::kInsertOmittedRequestType)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for request types."); + return false; + } + LOG4CXX_WARN(logger_, "Request types omitted."); + query_omitted.Bind(0, app_id); + if (!query_omitted.Exec() || !query_omitted.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request types."); + return false; + } + } + return true; +} + +bool SQLPTRepresentation::SaveRequestSubType( + const std::string& app_id, + const policy_table::RequestSubTypes& request_subtypes) { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kInsertRequestSubType)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for request subtypes."); + return false; } + policy_table::Strings::const_iterator it; + if (!request_subtypes.empty()) { + LOG4CXX_TRACE(logger_, "Request subtypes are not empty."); + for (it = request_subtypes.begin(); it != request_subtypes.end(); ++it) { + query.Bind(0, app_id); + query.Bind(1, *it); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); + return false; + } + } + } else if (request_subtypes.is_initialized()) { + LOG4CXX_WARN(logger_, "Request subtypes empty."); + query.Bind(0, app_id); + query.Bind(1, std::string("EMPTY")); + if (!query.Exec() || !query.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); + return false; + } + } else { + utils::dbms::SQLQuery query_omitted(db()); + if (!query_omitted.Prepare(sql_pt::kInsertOmittedRequestSubType)) { + LOG4CXX_WARN(logger_, "Incorrect insert statement for request subtypes."); + return false; + } + LOG4CXX_WARN(logger_, "Request subtypes omitted."); + query_omitted.Bind(0, app_id); + if (!query_omitted.Exec() || !query_omitted.Reset()) { + LOG4CXX_WARN(logger_, "Incorrect insert into request subtypes."); + return false; + } + } return true; } @@ -1529,11 +1611,36 @@ bool SQLPTRepresentation::GatherRequestType( if (!policy_table::EnumFromJsonString(query.GetString(0), &type)) { return false; } + if (policy_table::RequestType::RT_EMPTY == type) { + request_types->mark_initialized(); + continue; + } request_types->push_back(type); } return true; } +bool SQLPTRepresentation::GatherRequestSubType( + const std::string& app_id, + policy_table::RequestSubTypes* request_subtypes) const { + utils::dbms::SQLQuery query(db()); + if (!query.Prepare(sql_pt::kSelectRequestSubTypes)) { + LOG4CXX_WARN(logger_, "Incorrect select from request subtypes."); + return false; + } + + query.Bind(0, app_id); + while (query.Next()) { + const std::string request_subtype = query.GetString(0); + if ("EMPTY" == request_subtype) { + request_subtypes->mark_initialized(); + continue; + } + request_subtypes->push_back(request_subtype); + } + return true; +} + bool SQLPTRepresentation::GatherNickName( const std::string& app_id, policy_table::Strings* nicknames) const { utils::dbms::SQLQuery query(db()); @@ -1858,6 +1965,13 @@ bool SQLPTRepresentation::SetDefaultPolicy(const std::string& app_id) { !SaveRequestType(app_id, request_types)) { return false; } + + policy_table::Strings request_subtypes; + if (!GatherRequestSubType(kDefaultId, &request_subtypes) || + !SaveRequestSubType(app_id, request_subtypes)) { + return false; + } + policy_table::AppHMITypes app_types; if (!GatherAppType(kDefaultId, &app_types) || !SaveAppType(app_id, app_types)) { diff --git a/src/components/policy/policy_regular/test/sdl_preloaded_pt.json b/src/components/policy/policy_regular/test/sdl_preloaded_pt.json index c5386f612e..ced0a9d603 100644 --- a/src/components/policy/policy_regular/test/sdl_preloaded_pt.json +++ b/src/components/policy/policy_regular/test/sdl_preloaded_pt.json @@ -20,6 +20,7 @@ "notifications_per_minute_by_priority": { "EMERGENCY": 60, "NAVIGATION": 15, + "PROJECTION": 15, "COMMUNICATION": 6, "NORMAL": 4, "NONE": 0 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 fd83c82b1a..a5f3741331 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 @@ -289,6 +289,7 @@ class SQLPTRepresentationTest : public SQLPTRepresentation, 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); @@ -300,6 +301,9 @@ class SQLPTRepresentationTest : public SQLPTRepresentation, 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); @@ -310,6 +314,8 @@ class SQLPTRepresentationTest : public SQLPTRepresentation, 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["device"] = Json::Value(Json::objectValue); app_policies["device"]["groups"] = Json::Value(Json::arrayValue); app_policies["device"]["groups"][0] = Json::Value("default"); @@ -420,7 +426,9 @@ TEST_F(SQLPTRepresentationTest, ASSERT_EQ(0, dbms->FetchOneInt(query_select)); ASSERT_TRUE(reps->RefreshDB()); // Check PT structure destroyed and tables number is 0 - const int32_t total_tables_number = 28; + + // There are 29 tables in the database, now. + const int32_t total_tables_number = 29; ASSERT_EQ(total_tables_number, dbms->FetchOneInt(query_select)); const char* query_select_count_of_iap_buffer_full = "SELECT `count_of_iap_buffer_full` FROM `usage_and_error_count`"; 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 77de1705da..8525b1c5b9 100644 --- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc +++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc @@ -1989,7 +1989,8 @@ TEST_F(ProtocolHandlerImplTest, SendHeartBeat_Successful) { transport_manager_mock, SendMessageToDevice(ExpectedMessage( FRAME_TYPE_CONTROL, FRAME_DATA_HEART_BEAT, PROTECTION_OFF, kControl))) - .WillOnce(Return(E_SUCCESS)); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); + times++; // Act protocol_handler_impl->SendHeartBeat(connection_id, session_id); @@ -2086,7 +2087,8 @@ TEST_F(ProtocolHandlerImplTest, transport_manager_mock, SendMessageToDevice(ExpectedMessage( FRAME_TYPE_SINGLE, FRAME_DATA_SINGLE, PROTECTION_OFF, kControl))) - .WillOnce(Return(E_SUCCESS)); + .WillOnce(DoAll(NotifyTestAsyncWaiter(waiter), Return(E_SUCCESS))); + times++; // Act protocol_handler_impl->SendMessageToMobileApp(message, is_final); diff --git a/src/components/remote_control/test/include/mock_application.h b/src/components/remote_control/test/include/mock_application.h index ef7c1d63a7..33f596f7d4 100644 --- a/src/components/remote_control/test/include/mock_application.h +++ b/src/components/remote_control/test/include/mock_application.h @@ -113,6 +113,8 @@ class MockApplication : public ::application_manager::Application { MOCK_CONST_METHOD0(system_context, const mobile_apis::SystemContext::eType()); MOCK_CONST_METHOD0(audio_streaming_state, const mobile_apis::AudioStreamingState::eType()); + MOCK_CONST_METHOD0(video_streaming_state, + const mobile_apis::VideoStreamingState::eType()); MOCK_CONST_METHOD0(app_icon_path, const std::string&()); MOCK_CONST_METHOD0(device, connection_handler::DeviceHandle()); MOCK_CONST_METHOD0(CurrentHmiState, const application_manager::HmiStatePtr()); @@ -177,6 +179,7 @@ class MockApplication : public ::application_manager::Application { MOCK_METHOD1(IsSubscribedToSoftButton, bool(const uint32_t softbutton_id)); MOCK_METHOD1(UnsubscribeFromSoftButtons, void(int32_t cmd_id)); MOCK_CONST_METHOD0(IsAudioApplication, bool()); + MOCK_CONST_METHOD0(IsVideoApplication, bool()); MOCK_METHOD0(LoadPersistentFiles, void()); // InitialApplicationData methods MOCK_CONST_METHOD0(app_types, const smart_objects::SmartObject*()); diff --git a/tools/infrastructure/check_style.sh b/tools/infrastructure/check_style.sh index 647427e793..08ae1b9860 100755 --- a/tools/infrastructure/check_style.sh +++ b/tools/infrastructure/check_style.sh @@ -58,6 +58,19 @@ if [ "$1" = "--fix" ] then for FILE_NAME in $FILE_NAMES; do fix_style $FILE_NAME; done else - for FILE_NAME in $FILE_NAMES; do check_style $FILE_NAME; done + PASSED=0 + for FILE_NAME in $FILE_NAMES; do + check_style $FILE_NAME + if [ $? != 0 ] + then + echo "in " $FILE_NAME + PASSED=1 + fi + done + if [ $PASSED = 1 ] + then + exit 1 + fi fi + |