diff options
18 files changed, 437 insertions, 126 deletions
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index d5f9f9b7f8..4f4faa15a8 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 @@ -553,7 +553,8 @@ class ApplicationManagerImpl void StartDevicesDiscovery(); void RemoveHMIFakeParameters( - application_manager::commands::MessageSharedPtr& message) OVERRIDE; + application_manager::commands::MessageSharedPtr& message, + const hmi_apis::FunctionID::eType& function_id) OVERRIDE; /** * @brief TerminateRequest forces termination of request diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc index 88df9d8382..cfd8caae39 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/src/commands/mobile/set_interior_vehicle_data_request.cc @@ -267,6 +267,32 @@ ModuleCapability GetLightNameCapabilities( capabilitiesStatus::missedLightName); } +ModuleCapability GetRadioBandByCapabilities( + const smart_objects::SmartObject& capabilities_status, + const smart_objects::SmartObject& request_parameter) { + mobile_apis::RadioBand::eType radio_band = + static_cast<mobile_apis::RadioBand::eType>(request_parameter.asUInt()); + if (mobile_apis::RadioBand::XM == radio_band) { + if (!capabilities_status.keyExists(strings::kSiriusxmRadioAvailable)) { + LOG4CXX_DEBUG(logger_, + "Capability " + << strings::kSiriusxmRadioAvailable + << " is missed in RemoteControl capabilities"); + return std::make_pair(strings::kSiriusxmRadioAvailable, + capabilitiesStatus::missedParam); + } + if (!capabilities_status[strings::kSiriusxmRadioAvailable].asBool()) { + LOG4CXX_DEBUG(logger_, + "Capability " + << strings::kSiriusxmRadioAvailable + << " is switched off in RemoteControl capabilities"); + return std::make_pair(strings::kSiriusxmRadioAvailable, + capabilitiesStatus::missedParam); + } + } + return std::make_pair("", capabilitiesStatus::success); +} + /** * @brief Check whether the exists light data related to correspondent * capabilities @@ -303,40 +329,18 @@ ModuleCapability GetControlDataCapabilities( return light_capability; } - - const capabilitiesStatus status_item_capability = - GetItemCapability(capabilities[0], - mapping, - request_parameter, - mobile_apis::Result::UNSUPPORTED_RESOURCE); - - if (capabilitiesStatus::success != status_item_capability) { - return std::make_pair("", status_item_capability); + if (message_params::kBand == request_parameter) { + ModuleCapability radio_capability = GetRadioBandByCapabilities( + capabilities, control_data[request_parameter]); + if (capabilitiesStatus::success != radio_capability.second) { + return radio_capability; + } } - } - - return std::make_pair("", capabilitiesStatus::success); -} - -/** - * @brief Check whether the exists hmi data related to correspondent - * capabilities - * @param smart object of capabilities - * @param smart object of control_data - * @return pair of state and capability status - ModuleCapability - */ -ModuleCapability GetHmiControlDataCapabilities( - const smart_objects::SmartObject& capabilities, - const smart_objects::SmartObject& control_data) { - LOG4CXX_AUTO_TRACE(logger_); - std::map<std::string, std::string> mapping = - GetModuleDataToCapabilitiesMapping(); - for (auto it = control_data.map_begin(); it != control_data.map_end(); ++it) { const capabilitiesStatus status_item_capability = GetItemCapability(capabilities, mapping, - it->first, + request_parameter, mobile_apis::Result::UNSUPPORTED_RESOURCE); if (capabilitiesStatus::success != status_item_capability) { @@ -376,12 +380,13 @@ ModuleCapability GetModuleDataCapabilities( const smart_objects::SmartObject& caps = rc_capabilities[capabilities_key]; - if (message_params::kHmiSettingsControlData == module_data_key) { + if (message_params::kHmiSettingsControlData == module_data_key || + message_params::kLightControlData == module_data_key) { module_data_capabilities = - GetHmiControlDataCapabilities(caps, module_data[module_data_key]); + GetControlDataCapabilities(caps, module_data[module_data_key]); } else { module_data_capabilities = - GetControlDataCapabilities(caps, module_data[module_data_key]); + GetControlDataCapabilities(caps[0], module_data[module_data_key]); } } } @@ -488,7 +493,8 @@ void SetInteriorVehicleDataRequest::Execute() { CutOffReadOnlyParams(module_data); } - application_manager_.RemoveHMIFakeParameters(message_); + application_manager_.RemoveHMIFakeParameters( + message_, hmi_apis::FunctionID::RC_SetInteriorVehicleData); app_mngr::ApplicationSharedPtr app = application_manager_.application(connection_key()); diff --git a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc index 47e1c9a389..b1cb8271f5 100644 --- a/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc +++ b/src/components/application_manager/rpc_plugins/rc_rpc_plugin/test/commands/set_interior_vehicle_data_request_test.cc @@ -184,7 +184,7 @@ TEST_F( EXPECT_CALL(mock_hmi_capabilities_, rc_capability()) .WillOnce(Return(nullptr)); - EXPECT_CALL(app_mngr_, RemoveHMIFakeParameters(_)); + EXPECT_CALL(app_mngr_, RemoveHMIFakeParameters(_, _)); EXPECT_CALL( mock_rpc_service_, diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index eaac84dcf2..b61a405aa4 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1691,10 +1691,21 @@ void ApplicationManagerImpl::TerminateRequest(const uint32_t connection_key, } void ApplicationManagerImpl::RemoveHMIFakeParameters( - application_manager::commands::MessageSharedPtr& message) { + application_manager::commands::MessageSharedPtr& message, + const hmi_apis::FunctionID::eType& function_id) { LOG4CXX_AUTO_TRACE(logger_); hmi_apis::HMI_API factory; + if (!(*message)[jhs::S_PARAMS].keyExists(jhs::S_FUNCTION_ID)) { + LOG4CXX_ERROR(logger_, + "RemoveHMIFakeParameters message missing function id"); + return; + } + mobile_apis::FunctionID::eType mobile_function_id = + static_cast<mobile_apis::FunctionID::eType>( + (*message)[jhs::S_PARAMS][jhs::S_FUNCTION_ID].asInt()); + (*message)[jhs::S_PARAMS][jhs::S_FUNCTION_ID] = function_id; factory.attachSchema(*message, true); + (*message)[jhs::S_PARAMS][jhs::S_FUNCTION_ID] = mobile_function_id; } bool ApplicationManagerImpl::Init(resumption::LastState& last_state, diff --git a/src/components/include/application_manager/application_manager.h b/src/components/include/application_manager/application_manager.h index 9b482b9e62..6df91d748c 100644 --- a/src/components/include/application_manager/application_manager.h +++ b/src/components/include/application_manager/application_manager.h @@ -316,7 +316,8 @@ class ApplicationManager { virtual const std::set<int32_t> GetAppsSubscribedForWayPoints() const = 0; virtual void RemoveHMIFakeParameters( - application_manager::commands::MessageSharedPtr& message) = 0; + application_manager::commands::MessageSharedPtr& message, + const hmi_apis::FunctionID::eType& function_id) = 0; virtual mobile_api::HMILevel::eType GetDefaultHmiLevel( ApplicationConstSharedPtr application) const = 0; diff --git a/src/components/include/test/application_manager/mock_application_manager.h b/src/components/include/test/application_manager/mock_application_manager.h index e6e39bce58..f6a0c181c2 100644 --- a/src/components/include/test/application_manager/mock_application_manager.h +++ b/src/components/include/test/application_manager/mock_application_manager.h @@ -124,8 +124,9 @@ class MockApplicationManager : public application_manager::ApplicationManager { void(const std::shared_ptr<application_manager::Application> app)); MOCK_METHOD1(SendDriverDistractionState, void(application_manager::ApplicationSharedPtr app)); - MOCK_METHOD1(RemoveHMIFakeParameters, - void(application_manager::commands::MessageSharedPtr& message)); + MOCK_METHOD2(RemoveHMIFakeParameters, + void(application_manager::commands::MessageSharedPtr& message, + const hmi_apis::FunctionID::eType& function_id)); MOCK_CONST_METHOD1( GetDefaultHmiLevel, mobile_apis::HMILevel::eType( diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index b4d4d2c850..0b6eed072d 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -34,7 +34,7 @@ <interfaces name="SmartDeviceLink HMI API"> -<interface name="Common" version="1.7.0" date="2017-10-20"> +<interface name="Common" version="2.0.0" date="2018-09-05"> <enum name="Result"> <element name="SUCCESS" value="0"/> @@ -3426,7 +3426,7 @@ </function> </interface> -<interface name="BasicCommunication" version="1.2.1" date="2017-08-02"> +<interface name="BasicCommunication" version="2.0.0" date="2018-09-05"> <function name="GetSystemTime" messagetype="request"> <description>Request from SDL to HMI to obtain current UTC time.</description> </function> @@ -3920,7 +3920,7 @@ </function> </interface> -<interface name="TTS" version="1.1.0" date="2017-04-27"> +<interface name="TTS" version="2.0.0" date="2018-09-05"> <description>RPCs for communication between TTS and SDL.</description> <function name="GetCapabilities" messagetype="request"> <description>Method is invoked at system start-up. SDL requests the information about all supported hardware and their capabilities</description> @@ -4046,7 +4046,7 @@ </function> </interface> -<interface name="UI" version="1.2.0" date="2017-09-05"> +<interface name="UI" version="1.3.0" date="2018-09-05"> <function name="Alert" messagetype="request"> <description>Request from SDL to show an alert message on the display.</description> <param name="alertStrings" type="Common.TextFieldStruct" mandatory="true" array="true" minsize="0" maxsize="3"> @@ -4792,7 +4792,7 @@ </interface> -<interface name="VehicleInfo" version="1.1.0" date="2017-04-27"> +<interface name="VehicleInfo" version="2.0.0" date="2018-09-05"> <function name="IsReady" messagetype="request"> <description>Method is invoked at system startup. Response should provide information about presence of any of vehicle information modules (ECU, GPS, etc) and their readiness to cooperate with SDL.</description> </function> @@ -5505,7 +5505,7 @@ </interface> <!-- Policies --> -<interface name="SDL" version="1.1.0" date="2017-04-27"> +<interface name="SDL" version="1.2.0" date="2018-09-05"> <function name="ActivateApp" messagetype="request"> <param name="appID" type="Integer" mandatory="true"> </param> @@ -5678,7 +5678,7 @@ </function> </interface> -<interface name="RC" version="1.1.0" date="2017-07-18"> +<interface name="RC" version="2.0.0" date="2018-09-05"> <function name="IsReady" messagetype="request"> <description>Method is invoked at system startup. Response should provide information about presence of any of remote controllable module and its readiness to cooperate with SDL.</description> </function> diff --git a/src/components/interfaces/MOBILE_API.xml b/src/components/interfaces/MOBILE_API.xml index c36c4a4533..670793f1c4 100644 --- a/src/components/interfaces/MOBILE_API.xml +++ b/src/components/interfaces/MOBILE_API.xml @@ -3204,6 +3204,12 @@ <description>The short friendly name of the climate control module. It should not be used to identify a module by mobile application.</description> </param> + <param name="currentTemperatureAvailable" type="Boolean" mandatory="false" since="5.0"> + <description> + Availability of the reading of current temperature. + True: Available, False: Not Available, Not present: Not Available. + </description> + </param> <param name="fanSpeedAvailable" type="Boolean" mandatory="false"> <description> Availability of the control of fan speed. @@ -5987,11 +5993,14 @@ <element name="CORRUPTED_DATA"/> </param> - <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true"> + <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false" since="5.0"> <description> Provides the total local space available in SDL Core for the registered app. If the transfer has systemFile enabled, then the value will be set to 0 automatically. </description> + <history> + <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true" since="3.0" until="5.0"/> + </history> </param> <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation"> @@ -6032,8 +6041,14 @@ <element name="UNSUPPORTED_REQUEST"/> </param> - <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true"> - <description>Provides the total local space available on the module for the registered app.</description> + <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false" since="5.0"> + <description> + Provides the total local space available in SDL Core for the registered app. + If the transfer has systemFile enabled, then the value will be set to 0 automatically. + </description> + <history> + <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true" since="3.0" until="5.0"/> + </history> </param> <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation"> @@ -6076,8 +6091,14 @@ </description> </param> - <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true"> - <description>Provides the total local space available on the module for the registered app.</description> + <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="false" since="5.0"> + <description> + Provides the total local space available in SDL Core for the registered app. + If the transfer has systemFile enabled, then the value will be set to 0 automatically. + </description> + <history> + <param name="spaceAvailable" type="Integer" minvalue="0" maxvalue="2000000000" mandatory="true" since="3.0" until="5.0"/> + </history> </param> <param name="info" type="String" maxlength="1000" mandatory="false" platform="documentation"> 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 646cc7663b..dd9e0204e7 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 @@ -79,8 +79,6 @@ 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; 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 ee53eb1487..97d75731ea 100644 --- a/src/components/policy/policy_external/src/sql_pt_queries.cc +++ b/src/components/policy/policy_external/src/sql_pt_queries.cc @@ -645,19 +645,11 @@ 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 = 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 34c5b90903..31c69e3725 100644 --- a/src/components/policy/policy_external/src/sql_pt_representation.cc +++ b/src/components/policy/policy_external/src/sql_pt_representation.cc @@ -1193,18 +1193,6 @@ bool SQLPTRepresentation::SaveRequestType( 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; } @@ -1237,18 +1225,6 @@ bool SQLPTRepresentation::SaveRequestSubType( 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; } 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 5259ffa7e9..191873efe0 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 @@ -79,8 +79,6 @@ 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; diff --git a/src/components/policy/policy_regular/src/sql_pt_queries.cc b/src/components/policy/policy_regular/src/sql_pt_queries.cc index 91a5573a04..f5ccffce3b 100644 --- a/src/components/policy/policy_regular/src/sql_pt_queries.cc +++ b/src/components/policy/policy_regular/src/sql_pt_queries.cc @@ -595,19 +595,11 @@ const std::string kInsertRequestType = "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 = 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 d32ee7133d..4f5dbc4c3b 100644 --- a/src/components/policy/policy_regular/src/sql_pt_representation.cc +++ b/src/components/policy/policy_regular/src/sql_pt_representation.cc @@ -1137,18 +1137,6 @@ bool SQLPTRepresentation::SaveRequestType( 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; } @@ -1181,18 +1169,6 @@ bool SQLPTRepresentation::SaveRequestSubType( 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; } diff --git a/src/components/protocol_handler/src/protocol_handler_impl.cc b/src/components/protocol_handler/src/protocol_handler_impl.cc index 093d89490b..138a18df3f 100644 --- a/src/components/protocol_handler/src/protocol_handler_impl.cc +++ b/src/components/protocol_handler/src/protocol_handler_impl.cc @@ -1556,15 +1556,9 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession( logger_, "Protocol version:" << static_cast<int>(packet->protocol_version())); const ServiceType service_type = ServiceTypeFromByte(packet->service_type()); - BsonObject bson_obj; - if (packet->data() != NULL) { - bson_obj = bson_object_from_bytes(packet->data()); - } else { - bson_object_initialize_default(&bson_obj); - } -#ifdef ENABLE_SECURITY const uint8_t protocol_version = packet->protocol_version(); +#ifdef ENABLE_SECURITY const bool protection = // Protocol version 1 does not support protection (protocol_version > PROTOCOL_VERSION_1) ? packet->protection_flag() @@ -1575,6 +1569,31 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession( const ConnectionID connection_id = packet->connection_id(); const uint8_t session_id = packet->session_id(); + const std::string& transport = + session_observer_.TransportTypeProfileStringFromConnHandle(connection_id); + + const auto video_transports = settings_.video_service_transports(); + const bool is_video_allowed = + video_transports.empty() || + std::find(video_transports.begin(), video_transports.end(), transport) != + video_transports.end(); + + const auto audio_transports = settings_.audio_service_transports(); + const bool is_audio_allowed = + audio_transports.empty() || + std::find(audio_transports.begin(), audio_transports.end(), transport) != + audio_transports.end(); + + if ((ServiceType::kMobileNav == service_type && !is_video_allowed) || + (ServiceType::kAudio == service_type && !is_audio_allowed)) { + LOG4CXX_DEBUG(logger_, + "Rejecting StartService for service:" + << service_type << ", over transport: " << transport + << ", disallowed by settings."); + SendStartSessionNAck( + connection_id, session_id, protocol_version, service_type); + return RESULT_OK; + } LOG4CXX_INFO(logger_, "StartSession ID " << static_cast<int>(session_id) @@ -1587,6 +1606,13 @@ RESULT_CODE ProtocolHandlerImpl::HandleControlMessageStartSession( packet; } + BsonObject bson_obj; + if (packet->data() != NULL) { + bson_obj = bson_object_from_bytes(packet->data()); + } else { + bson_object_initialize_default(&bson_obj); + } + session_observer_.OnSessionStartedCallback( connection_id, packet->session_id(), service_type, protection, &bson_obj); bson_object_deinitialize(&bson_obj); 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 615900c7fa..51284dfcda 100644 --- a/src/components/protocol_handler/test/protocol_handler_tm_test.cc +++ b/src/components/protocol_handler/test/protocol_handler_tm_test.cc @@ -269,6 +269,21 @@ class ProtocolHandlerImplTest : public ::testing::Test { HASH_ID_WRONG, callback_protection_flag); + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector<std::string> audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector<std::string> video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -452,6 +467,24 @@ TEST_F(ProtocolHandlerImplTest, TestAsyncWaiter waiter; uint32_t times = 0; ServiceType service_type; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .Times(call_times) + .WillRepeatedly(Return("TCP_WIFI")); + + std::vector<std::string> audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector<std::string> video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .Times(call_times) + .WillRepeatedly(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .Times(call_times) + .WillRepeatedly(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL( session_observer_mock, @@ -520,6 +553,24 @@ TEST_F(ProtocolHandlerImplTest, StartSession_Protected_SessionObserverReject) { TestAsyncWaiter waiter; uint32_t times = 0; ServiceType service_type; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .Times(call_times) + .WillRepeatedly(Return("TCP_WIFI")); + + std::vector<std::string> audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector<std::string> video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .Times(call_times) + .WillRepeatedly(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .Times(call_times) + .WillRepeatedly(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL( session_observer_mock, @@ -578,6 +629,21 @@ TEST_F(ProtocolHandlerImplTest, TestAsyncWaiter waiter; uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector<std::string> audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector<std::string> video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -694,6 +760,26 @@ TEST_F(ProtocolHandlerImplTest, TestAsyncWaiter waiter; uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id1)) + .WillOnce(Return("TCP_WIFI")); + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id2)) + .WillOnce(Return("TCP_WIFI")); + + std::vector<std::string> audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector<std::string> video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .Times(2) + .WillRepeatedly(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .Times(2) + .WillRepeatedly(ReturnRef(video_service_transports)); + BsonObject bson_params1; bson_object_initialize_default(&bson_params1); bson_object_put_string(&bson_params1, @@ -830,6 +916,84 @@ TEST_F(ProtocolHandlerImplTest, bson_object_deinitialize(&bson_params2); } +/* + * ProtocolHandler shall send NAck on session_observer rejection + * Check protection flag OFF for all services from kControl to kBulk + */ +TEST_F(ProtocolHandlerImplTest, StartSession_Audio_RejectByTransportType) { + using namespace protocol_handler; + AddConnection(); + const ServiceType start_service = kAudio; + + TestAsyncWaiter waiter; + uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector<std::string> audio_service_transports; + audio_service_transports.push_back("AOA_USB"); + std::vector<std::string> video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + + // Expect send Ack + EXPECT_CALL(transport_manager_mock, + SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_NACK, + PROTECTION_OFF))) + .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + times++; + + SendControlMessage( + PROTECTION_OFF, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE); + + EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); +} + +/* + * ProtocolHandler shall send NAck on session_observer rejection + * Check protection flag OFF for all services from kControl to kBulk + */ +TEST_F(ProtocolHandlerImplTest, StartSession_Video_RejectByTransportType) { + using namespace protocol_handler; + AddConnection(); + const ServiceType start_service = kMobileNav; + + TestAsyncWaiter waiter; + uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector<std::string> audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector<std::string> video_service_transports; + video_service_transports.push_back("AOA_USB"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + + // Expect send Ack + EXPECT_CALL(transport_manager_mock, + SendMessageToDevice(ControlMessage(FRAME_DATA_START_SERVICE_NACK, + PROTECTION_OFF))) + .WillOnce(DoAll(NotifyTestAsyncWaiter(&waiter), Return(E_SUCCESS))); + times++; + + SendControlMessage( + PROTECTION_OFF, start_service, NEW_SESSION_ID, FRAME_DATA_START_SERVICE); + + EXPECT_TRUE(waiter.WaitFor(times, kAsyncExpectationsTimeout)); +} + // TODO(EZamakhov): add test for get_hash_id/set_hash_id from // protocol_handler_impl.cc /* @@ -910,6 +1074,21 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtocoloV1) { // Add security manager AddSecurityManager(); const ServiceType start_service = kRpc; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector<std::string> audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector<std::string> video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -966,6 +1145,21 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionUnprotected) { TestAsyncWaiter waiter; uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector<std::string> audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector<std::string> video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1021,6 +1215,21 @@ TEST_F(ProtocolHandlerImplTest, SecurityEnable_StartSessionProtected_Fail) { PROTECTION_ON); context.is_new_service_ = true; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector<std::string> audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector<std::string> video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1074,6 +1283,21 @@ TEST_F(ProtocolHandlerImplTest, TestAsyncWaiter waiter; uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector<std::string> audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector<std::string> video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1150,6 +1374,21 @@ TEST_F(ProtocolHandlerImplTest, PROTECTION_ON); context.is_new_service_ = true; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector<std::string> audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector<std::string> video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1231,6 +1470,21 @@ TEST_F(ProtocolHandlerImplTest, TestAsyncWaiter waiter; uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector<std::string> audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector<std::string> video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1329,6 +1583,21 @@ TEST_F( TestAsyncWaiter waiter; uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector<std::string> audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector<std::string> video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, @@ -1425,6 +1694,21 @@ TEST_F(ProtocolHandlerImplTest, TestAsyncWaiter waiter; uint32_t times = 0; + // Expect verification of allowed transport + EXPECT_CALL(session_observer_mock, + TransportTypeProfileStringFromConnHandle(connection_id)) + .WillOnce(Return("TCP_WIFI")); + + std::vector<std::string> audio_service_transports; + audio_service_transports.push_back("TCP_WIFI"); + std::vector<std::string> video_service_transports; + video_service_transports.push_back("TCP_WIFI"); + + EXPECT_CALL(protocol_handler_settings_mock, audio_service_transports()) + .WillOnce(ReturnRef(audio_service_transports)); + EXPECT_CALL(protocol_handler_settings_mock, video_service_transports()) + .WillOnce(ReturnRef(video_service_transports)); + // Expect ConnectionHandler check EXPECT_CALL(session_observer_mock, OnSessionStartedCallback(connection_id, diff --git a/src/components/transport_manager/include/transport_manager/iap2_emulation/iap2_transport_adapter.h b/src/components/transport_manager/include/transport_manager/iap2_emulation/iap2_transport_adapter.h index 36a2b374dd..e53a472bcb 100644 --- a/src/components/transport_manager/include/transport_manager/iap2_emulation/iap2_transport_adapter.h +++ b/src/components/transport_manager/include/transport_manager/iap2_emulation/iap2_transport_adapter.h @@ -74,6 +74,15 @@ class IAP2BluetoothEmulationTransportAdapter : public TcpTransportAdapter { */ void DeviceSwitched(const DeviceUID& device_handle) OVERRIDE; + /** + * @brief Notification that transport's configuration is updated. This + * override is needed so that a OnTransportConfigUpdated is not sent to the + * mobile device for the emulated transport. + * + * @param new_config The new configuration of the transport + */ + void TransportConfigUpdated(const TransportConfig& new_config) OVERRIDE; + protected: /** * @brief GetDeviceType Provides SDL device type for transport adapter @@ -110,6 +119,15 @@ class IAP2USBEmulationTransportAdapter : public TcpTransportAdapter { */ void DeviceSwitched(const DeviceUID& device_handle) OVERRIDE; + /** + * @brief Notification that transport's configuration is updated. This + * override is needed so that a OnTransportConfigUpdated is not sent to the + * mobile device for the emulated transport. + * + * @param new_config The new configuration of the transport + */ + void TransportConfigUpdated(const TransportConfig& new_config) OVERRIDE; + protected: /** * @brief GetDeviceType Provides SDL device type for transport adapter diff --git a/src/components/transport_manager/src/iap2_emulation/iap2_transport_adapter.cc b/src/components/transport_manager/src/iap2_emulation/iap2_transport_adapter.cc index e2e5b98190..31e997f3ba 100644 --- a/src/components/transport_manager/src/iap2_emulation/iap2_transport_adapter.cc +++ b/src/components/transport_manager/src/iap2_emulation/iap2_transport_adapter.cc @@ -69,6 +69,11 @@ DeviceType IAP2BluetoothEmulationTransportAdapter::GetDeviceType() const { return IOS_BT; } +void IAP2BluetoothEmulationTransportAdapter::TransportConfigUpdated( + const TransportConfig& new_config) { + return; +} + IAP2USBEmulationTransportAdapter::IAP2USBEmulationTransportAdapter( const uint16_t port, resumption::LastState& last_state, @@ -120,6 +125,11 @@ DeviceType IAP2USBEmulationTransportAdapter::GetDeviceType() const { return IOS_USB; } +void IAP2USBEmulationTransportAdapter::TransportConfigUpdated( + const TransportConfig& new_config) { + return; +} + IAP2USBEmulationTransportAdapter::IAPSignalHandlerDelegate:: IAPSignalHandlerDelegate(IAP2USBEmulationTransportAdapter& adapter) : adapter_(adapter), run_flag_(true), in_(0) { |