summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/application_manager/include/application_manager/application_manager_impl.h25
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc31
-rw-r--r--src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc5
-rw-r--r--src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc8
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc3
-rw-r--r--src/components/application_manager/test/application_manager_impl_test.cc117
-rw-r--r--src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc3
-rw-r--r--src/components/application_manager/test/commands/mobile/perform_audio_pass_thru_test.cc41
-rw-r--r--src/components/application_manager/test/policy_handler_test.cc1
-rw-r--r--src/components/hmi_message_handler/include/hmi_message_handler/mb_controller.h2
-rw-r--r--src/components/hmi_message_handler/include/hmi_message_handler/websocket_session.h2
-rw-r--r--src/components/hmi_message_handler/src/mb_controller.cc4
-rw-r--r--src/components/hmi_message_handler/src/websocket_session.cc2
-rw-r--r--src/components/include/application_manager/application_manager.h21
-rw-r--r--src/components/include/test/application_manager/mock_application_manager.h6
-rw-r--r--src/components/include/test/media_manager/mock_media_manager.h2
-rw-r--r--src/components/policy/policy_external/src/policy_manager_impl.cc24
-rw-r--r--src/components/policy/policy_regular/src/policy_manager_impl.cc10
18 files changed, 262 insertions, 45 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 3e7fab60fb..286ad87018 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
@@ -478,18 +478,35 @@ class ApplicationManagerImpl
uint32_t GetNextHMICorrelationID() OVERRIDE;
/* @brief Starts audio passthru process
+ * @deprecated Use BeginAudioPassThru(uint32_t app_id) instead
*
* @return true on success, false if passthru is already in process
*/
bool BeginAudioPassThrough() OVERRIDE;
+ /**
+ * @brief Starts AudioPassThru process by given application
+ * @param app_id ID of the application which starts the process
+ * @return true if AudioPassThru can be started, false otherwise
+ */
+ bool BeginAudioPassThru(uint32_t app_id) OVERRIDE;
+
/*
* @brief Finishes already started audio passthru process
+ * @deprecated Use EndAudioPassThru(uint32_t app_id) instead
*
* @return true on success, false if passthru is not active
*/
bool EndAudioPassThrough() OVERRIDE;
+ /**
+ * @brief Finishes already started AudioPassThru process by given application
+ * @param app_id ID of the application which started the process
+ * @return true if AudioPassThru process has been started with given
+ * application and thus it can be stopped, false otherwise
+ */
+ bool EndAudioPassThru(uint32_t app_id) OVERRIDE;
+
/*
* @brief Retrieves driver distraction state
*
@@ -1702,6 +1719,7 @@ class ApplicationManagerImpl
std::map<uint32_t, TimevalStruct> tts_global_properties_app_list_;
bool audio_pass_thru_active_;
+ uint32_t audio_pass_thru_app_id_;
sync_primitives::Lock audio_pass_thru_lock_;
sync_primitives::Lock tts_global_properties_app_list_lock_;
hmi_apis::Common_DriverDistractionState::eType driver_distraction_state_;
@@ -1820,6 +1838,13 @@ class ApplicationManagerImpl
*/
void AddMockApplication(ApplicationSharedPtr mock_app);
+ /**
+ * @brief set a mock media manager without running Init(). Only for unit
+ * testing.
+ * @param mock_app the mock app to be registered
+ */
+ void SetMockMediaManager(media_manager::MediaManager* mock_media_manager);
+
private:
#endif
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index f16c21ea84..248b54fee5 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -143,6 +143,7 @@ ApplicationManagerImpl::ApplicationManagerImpl(
: settings_(am_settings)
, applications_list_lock_(true)
, audio_pass_thru_active_(false)
+ , audio_pass_thru_app_id_(0)
, driver_distraction_state_(
hmi_apis::Common_DriverDistractionState::INVALID_ENUM)
, is_vr_session_strated_(false)
@@ -784,6 +785,17 @@ bool ApplicationManagerImpl::BeginAudioPassThrough() {
}
}
+bool ApplicationManagerImpl::BeginAudioPassThru(uint32_t app_id) {
+ sync_primitives::AutoLock lock(audio_pass_thru_lock_);
+ if (audio_pass_thru_active_) {
+ return false;
+ } else {
+ audio_pass_thru_active_ = true;
+ audio_pass_thru_app_id_ = app_id;
+ return true;
+ }
+}
+
bool ApplicationManagerImpl::EndAudioPassThrough() {
sync_primitives::AutoLock lock(audio_pass_thru_lock_);
if (audio_pass_thru_active_) {
@@ -794,6 +806,17 @@ bool ApplicationManagerImpl::EndAudioPassThrough() {
}
}
+bool ApplicationManagerImpl::EndAudioPassThru(uint32_t app_id) {
+ sync_primitives::AutoLock lock(audio_pass_thru_lock_);
+ if (audio_pass_thru_active_ && audio_pass_thru_app_id_ == app_id) {
+ audio_pass_thru_active_ = false;
+ audio_pass_thru_app_id_ = 0;
+ return true;
+ } else {
+ return false;
+ }
+}
+
hmi_apis::Common_DriverDistractionState::eType
ApplicationManagerImpl::driver_distraction_state() const {
return driver_distraction_state_;
@@ -3222,9 +3245,8 @@ void ApplicationManagerImpl::UnregisterApplication(
commands_holder_->Clear(app_to_remove);
- if (audio_pass_thru_active_) {
+ if (EndAudioPassThru(app_id)) {
// May be better to put this code in MessageHelper?
- EndAudioPassThrough();
StopAudioPassThru(app_id);
MessageHelper::SendStopAudioPathThru(*this);
}
@@ -4441,6 +4463,11 @@ void ApplicationManagerImpl::AddMockApplication(ApplicationSharedPtr mock_app) {
apps_size_ = applications_.size();
applications_list_lock_.Release();
}
+
+void ApplicationManagerImpl::SetMockMediaManager(
+ media_manager::MediaManager* mock_media_manager) {
+ media_manager_ = mock_media_manager;
+}
#endif // BUILD_TESTS
#ifdef SDL_REMOTE_CONTROL
struct MobileAppIdPredicate {
diff --git a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
index 0bd83078e5..fb168e4256 100644
--- a/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
+++ b/src/components/application_manager/src/commands/mobile/end_audio_pass_thru_request.cc
@@ -66,9 +66,10 @@ void EndAudioPassThruRequest::on_event(const event_engine::Event& event) {
const bool result = PrepareResultForMobileResponse(
result_code, HmiInterfaces::HMI_INTERFACE_UI);
if (result) {
- bool ended_successfully = application_manager_.EndAudioPassThrough();
+ uint32_t app_id = connection_key();
+ bool ended_successfully = application_manager_.EndAudioPassThru(app_id);
if (ended_successfully) {
- application_manager_.StopAudioPassThru(connection_key());
+ application_manager_.StopAudioPassThru(app_id);
}
}
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 a05d41c098..20076ac50c 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
@@ -311,7 +311,8 @@ void PerformAudioPassThruRequest::SendRecordStartNotification() {
void PerformAudioPassThruRequest::StartMicrophoneRecording() {
LOG4CXX_AUTO_TRACE(logger_);
- application_manager_.BeginAudioPassThrough();
+ uint32_t app_id = connection_key();
+ application_manager_.BeginAudioPassThru(app_id);
application_manager_.StartAudioPassThruThread(
connection_key(),
@@ -370,9 +371,10 @@ bool PerformAudioPassThruRequest::IsWhiteSpaceExist() {
void PerformAudioPassThruRequest::FinishTTSSpeak() {
LOG4CXX_AUTO_TRACE(logger_);
- if (application_manager_.EndAudioPassThrough()) {
+ uint32_t app_id = connection_key();
+ if (application_manager_.EndAudioPassThru(app_id)) {
LOG4CXX_DEBUG(logger_, "Stop AudioPassThru.");
- application_manager_.StopAudioPassThru(connection_key());
+ application_manager_.StopAudioPassThru(app_id);
}
if (!IsInterfaceAwaited(HmiInterfaces::HMI_INTERFACE_TTS)) {
LOG4CXX_WARN(logger_, "TTS Speak is inactive.");
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index bbf391a9f1..559b9c0035 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -1091,8 +1091,7 @@ bool PolicyHandler::ReceiveMessageFromSDK(const std::string& file,
MessageHelper::CreateGetVehicleDataRequest(
correlation_id, vehicle_data_args, application_manager_);
} else {
- LOG4CXX_WARN(logger_, "Exchange wasn't successful, trying another one.");
- policy_manager_->ForcePTExchange();
+ LOG4CXX_WARN(logger_, "Exchange wasn't successful");
}
OnPTUFinished(ret);
return ret;
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 e54bc612ca..c922c227bb 100644
--- a/src/components/application_manager/test/application_manager_impl_test.cc
+++ b/src/components/application_manager/test/application_manager_impl_test.cc
@@ -47,6 +47,7 @@
#include "application_manager/test/include/application_manager/mock_message_helper.h"
#include "connection_handler/mock_connection_handler.h"
#include "hmi_message_handler/mock_hmi_message_handler.h"
+#include "media_manager/mock_media_manager.h"
#include "policy/mock_policy_settings.h"
#include "policy/usage_statistics/mock_statistics_manager.h"
#include "protocol/bson_object_keys.h"
@@ -824,6 +825,122 @@ TEST_F(ApplicationManagerImplTest,
EXPECT_EQ(new_application_id, app_impl->app_id());
}
+TEST_F(ApplicationManagerImplTest, StartStopAudioPassThru) {
+ std::string dummy_file_name;
+ ON_CALL(mock_application_manager_settings_, recording_file_name())
+ .WillByDefault(ReturnRef(dummy_file_name));
+
+ NiceMock<test::components::media_manager_test::MockMediaManager>
+ mock_media_manager;
+ app_manager_impl_->SetMockMediaManager(&mock_media_manager);
+
+ const uint32_t app_id = 65537;
+ const int32_t max_duration = 1000;
+ // below are not used
+ const int32_t correlation_id = 0;
+ const int32_t sampling_rate = 0;
+ const int32_t bits_per_sample = 0;
+ const int32_t audio_type = 0;
+
+ EXPECT_CALL(mock_media_manager,
+ StartMicrophoneRecording(app_id, _, max_duration))
+ .WillOnce(Return());
+ EXPECT_CALL(mock_media_manager, StopMicrophoneRecording(app_id))
+ .WillOnce(Return());
+
+ bool result = app_manager_impl_->BeginAudioPassThru(app_id);
+ EXPECT_TRUE(result);
+ if (result) {
+ app_manager_impl_->StartAudioPassThruThread(app_id,
+ correlation_id,
+ max_duration,
+ sampling_rate,
+ bits_per_sample,
+ audio_type);
+ }
+
+ result = app_manager_impl_->EndAudioPassThru(app_id);
+ EXPECT_TRUE(result);
+ if (result) {
+ app_manager_impl_->StopAudioPassThru(app_id);
+ }
+}
+
+TEST_F(ApplicationManagerImplTest, UnregisterAnotherAppDuringAudioPassThru) {
+ std::string dummy_file_name;
+ ON_CALL(mock_application_manager_settings_, recording_file_name())
+ .WillByDefault(ReturnRef(dummy_file_name));
+
+ const uint32_t app_id_1 = 65537;
+ const uint32_t app_id_2 = 65538;
+
+ std::string dummy_mac_address;
+ utils::SharedPtr<MockApplication> mock_app_1 =
+ utils::SharedPtr<MockApplication>(new MockApplication());
+ EXPECT_CALL(*mock_app_1, app_id()).WillRepeatedly(Return(app_id_1));
+ EXPECT_CALL(*mock_app_1, device()).WillRepeatedly(Return(0));
+ EXPECT_CALL(*mock_app_1, mac_address())
+ .WillRepeatedly(ReturnRef(dummy_mac_address));
+ EXPECT_CALL(*mock_app_1, policy_app_id()).WillRepeatedly(Return(""));
+ EXPECT_CALL(*mock_app_1, protocol_version())
+ .WillRepeatedly(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4));
+
+ utils::SharedPtr<MockApplication> mock_app_2 =
+ utils::SharedPtr<MockApplication>(new MockApplication());
+ EXPECT_CALL(*mock_app_2, app_id()).WillRepeatedly(Return(app_id_2));
+ EXPECT_CALL(*mock_app_2, device()).WillRepeatedly(Return(0));
+ EXPECT_CALL(*mock_app_2, mac_address())
+ .WillRepeatedly(ReturnRef(dummy_mac_address));
+ EXPECT_CALL(*mock_app_2, policy_app_id()).WillRepeatedly(Return(""));
+ EXPECT_CALL(*mock_app_2, protocol_version())
+ .WillRepeatedly(
+ Return(protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_4));
+
+ NiceMock<test::components::media_manager_test::MockMediaManager>
+ mock_media_manager;
+ app_manager_impl_->SetMockMediaManager(&mock_media_manager);
+
+ app_manager_impl_->AddMockApplication(mock_app_1);
+ app_manager_impl_->AddMockApplication(mock_app_2);
+
+ const int32_t max_duration = 1000;
+ // below are not used
+ const int32_t correlation_id = 0;
+ const int32_t sampling_rate = 0;
+ const int32_t bits_per_sample = 0;
+ const int32_t audio_type = 0;
+
+ EXPECT_CALL(mock_media_manager,
+ StartMicrophoneRecording(app_id_2, _, max_duration))
+ .WillOnce(Return());
+ EXPECT_CALL(mock_media_manager, StopMicrophoneRecording(app_id_2))
+ .WillOnce(Return());
+
+ // app 2 starts Audio Pass Thru
+ bool result = app_manager_impl_->BeginAudioPassThru(app_id_2);
+ EXPECT_TRUE(result);
+ if (result) {
+ app_manager_impl_->StartAudioPassThruThread(app_id_2,
+ correlation_id,
+ max_duration,
+ sampling_rate,
+ bits_per_sample,
+ audio_type);
+ }
+
+ // while running APT, app 1 is unregistered
+ app_manager_impl_->UnregisterApplication(
+ app_id_1, mobile_apis::Result::SUCCESS, false, true);
+
+ // confirm that APT is still running
+ result = app_manager_impl_->EndAudioPassThru(app_id_2);
+ EXPECT_TRUE(result);
+ if (result) {
+ app_manager_impl_->StopAudioPassThru(app_id_2);
+ }
+}
+
} // application_manager_test
} // namespace components
} // namespace test
diff --git a/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc b/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc
index 33733f63ed..6b1d909121 100644
--- a/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc
+++ b/src/components/application_manager/test/commands/mobile/end_audio_pass_thru_request_test.cc
@@ -67,6 +67,7 @@ class EndAudioPassThruRequestTest
TEST_F(EndAudioPassThruRequestTest, OnEvent_UI_UNSUPPORTED_RESOUCRE) {
const uint32_t kConnectionKey = 2u;
+ const uint32_t app_id = kConnectionKey;
MessageSharedPtr command_msg(CreateMessage(smart_objects::SmartType_Map));
(*command_msg)[am::strings::params][am::strings::connection_key] =
@@ -83,7 +84,7 @@ TEST_F(EndAudioPassThruRequestTest, OnEvent_UI_UNSUPPORTED_RESOUCRE) {
Event event(hmi_apis::FunctionID::UI_EndAudioPassThru);
event.set_smart_object(*event_msg);
- EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false));
+ EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false));
MessageSharedPtr ui_command_result;
EXPECT_CALL(
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 6c35a5372a..a27bac970c 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
@@ -128,6 +128,8 @@ class PerformAudioPassThruRequestTest
ON_CALL(app_mngr_, application(kConnectionKey))
.WillByDefault(Return(mock_app_));
ON_CALL(*mock_app_, app_id()).WillByDefault(Return(kConnectionKey));
+ (*message_)[am::strings::params][am::strings::connection_key] =
+ kConnectionKey;
command_sptr_ =
CreateCommand<am::commands::PerformAudioPassThruRequest>(message_);
@@ -160,10 +162,15 @@ TEST_F(PerformAudioPassThruRequestTest, OnTimeout_GENERIC_ERROR) {
am::mobile_api::Result::GENERIC_ERROR;
(*msg_ui)[am::strings::msg_params][am::strings::success] = false;
+ MessageSharedPtr message =
+ utils::MakeShared<SmartObject>(::smart_objects::SmartType_Map);
+ (*message)[am::strings::params][am::strings::connection_key] = kConnectionKey;
+
utils::SharedPtr<PerformAudioPassThruRequest> command =
- CreateCommand<PerformAudioPassThruRequest>();
+ CreateCommand<PerformAudioPassThruRequest>(message);
- EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(true));
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true));
EXPECT_CALL(app_mngr_, StopAudioPassThru(_));
EXPECT_CALL(
@@ -232,7 +239,8 @@ TEST_F(PerformAudioPassThruRequestTest,
event_ui.set_smart_object(*response_ui);
MessageSharedPtr response_to_mobile;
- EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false));
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false));
EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillRepeatedly(Return(true));
EXPECT_CALL(
app_mngr_,
@@ -362,7 +370,8 @@ TEST_F(PerformAudioPassThruRequestTest,
hmi_apis::Common_Result::GENERIC_ERROR;
event.set_smart_object(*message_);
- EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false));
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false));
ON_CALL(app_mngr_, GetNextHMICorrelationID())
.WillByDefault(Return(kCorrelationId));
@@ -536,7 +545,8 @@ TEST_F(
}
// Start microphone recording cals
- EXPECT_CALL(app_mngr_, BeginAudioPassThrough());
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id));
EXPECT_CALL(app_mngr_, StartAudioPassThruThread(_, _, _, _, _, _));
CallRun caller(*command_sptr_);
@@ -581,7 +591,8 @@ TEST_F(PerformAudioPassThruRequestTest,
EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
// Start microphone recording cals
- EXPECT_CALL(app_mngr_, BeginAudioPassThrough());
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id));
EXPECT_CALL(app_mngr_, StartAudioPassThruThread(_, _, _, _, _, _));
EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _));
@@ -617,7 +628,8 @@ TEST_F(PerformAudioPassThruRequestTest,
caller_speak();
// Second call for test correct behavior of UI_PerformAudioPassThru event
- EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(false));
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(false));
EXPECT_CALL(app_mngr_, StopAudioPassThru(_)).Times(0);
ON_CALL(mock_hmi_interfaces_, GetInterfaceState(_))
.WillByDefault(Return(am::HmiInterfaces::STATE_AVAILABLE));
@@ -641,7 +653,8 @@ TEST_F(PerformAudioPassThruRequestTest,
EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
- EXPECT_CALL(app_mngr_, BeginAudioPassThrough()).WillOnce(Return(true));
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)).WillOnce(Return(true));
EXPECT_CALL(
app_mngr_,
@@ -664,8 +677,9 @@ TEST_F(PerformAudioPassThruRequestTest,
msg_params_[am::strings::connection_key] = kConnectionKey;
msg_params_[am::strings::function_id] = kFunctionId;
+ uint32_t app_id = kConnectionKey;
EXPECT_CALL(app_mngr_, ManageHMICommand(_)).WillOnce(Return(true));
- EXPECT_CALL(app_mngr_, BeginAudioPassThrough()).WillOnce(Return(true));
+ EXPECT_CALL(app_mngr_, BeginAudioPassThru(app_id)).WillOnce(Return(true));
EXPECT_CALL(
app_mngr_,
@@ -683,8 +697,9 @@ TEST_F(PerformAudioPassThruRequestTest,
TEST_F(PerformAudioPassThruRequestTest, OnEvent_DefaultCase) {
am::event_engine::Event event(hmi_apis::FunctionID::INVALID_ENUM);
+ uint32_t app_id = kConnectionKey;
EXPECT_CALL(app_mngr_, updateRequestTimeout(_, _, _)).Times(0);
- EXPECT_CALL(app_mngr_, EndAudioPassThrough()).Times(0);
+ EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).Times(0);
CallOnEvent caller(*command_sptr_, event);
caller();
@@ -703,7 +718,8 @@ TEST_F(PerformAudioPassThruRequestTest, Init_CorrectTimeout) {
TEST_F(PerformAudioPassThruRequestTest,
onTimeOut_ttsSpeakNotActive_DontSendHMIReqeust) {
- EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(true));
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true));
EXPECT_CALL(app_mngr_, StopAudioPassThru(_));
// For setting current_state_ -> kCompleted
@@ -717,7 +733,8 @@ TEST_F(PerformAudioPassThruRequestTest,
TEST_F(PerformAudioPassThruRequestTest,
DISABLED_onTimeOut_ttsSpeakActive_SendHMIReqeust) {
- EXPECT_CALL(app_mngr_, EndAudioPassThrough()).WillOnce(Return(true));
+ uint32_t app_id = kConnectionKey;
+ EXPECT_CALL(app_mngr_, EndAudioPassThru(app_id)).WillOnce(Return(true));
EXPECT_CALL(app_mngr_, StopAudioPassThru(_));
EXPECT_CALL(*application_sptr_, hmi_level())
diff --git a/src/components/application_manager/test/policy_handler_test.cc b/src/components/application_manager/test/policy_handler_test.cc
index 77500fd238..d9e1cefa01 100644
--- a/src/components/application_manager/test/policy_handler_test.cc
+++ b/src/components/application_manager/test/policy_handler_test.cc
@@ -408,7 +408,6 @@ TEST_F(PolicyHandlerTest, ReceiveMessageFromSDK_PTNotLoaded) {
// Checks
EXPECT_CALL(*mock_policy_manager_, LoadPT("", msg)).WillOnce(Return(false));
- EXPECT_CALL(*mock_policy_manager_, ForcePTExchange()).WillOnce(Return(""));
EXPECT_CALL(app_manager_, GetNextHMICorrelationID()).Times(0);
EXPECT_CALL(mock_message_helper_, CreateGetVehicleDataRequest(_, _, _))
.Times(0);
diff --git a/src/components/hmi_message_handler/include/hmi_message_handler/mb_controller.h b/src/components/hmi_message_handler/include/hmi_message_handler/mb_controller.h
index 1bd74e09ea..60dc50ad7a 100644
--- a/src/components/hmi_message_handler/include/hmi_message_handler/mb_controller.h
+++ b/src/components/hmi_message_handler/include/hmi_message_handler/mb_controller.h
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2018 Livio, Inc.
+Copyright (c) 2018 Livio, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/src/components/hmi_message_handler/include/hmi_message_handler/websocket_session.h b/src/components/hmi_message_handler/include/hmi_message_handler/websocket_session.h
index 5d82a35679..9692c4aef4 100644
--- a/src/components/hmi_message_handler/include/hmi_message_handler/websocket_session.h
+++ b/src/components/hmi_message_handler/include/hmi_message_handler/websocket_session.h
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2018 Livio, Inc.
+Copyright (c) 2018 Livio, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/src/components/hmi_message_handler/src/mb_controller.cc b/src/components/hmi_message_handler/src/mb_controller.cc
index df3c3f16b2..8d3b11add5 100644
--- a/src/components/hmi_message_handler/src/mb_controller.cc
+++ b/src/components/hmi_message_handler/src/mb_controller.cc
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2018 Livio, Inc.
+Copyright (c) 2018 Livio, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
+
#include "hmi_message_handler/mb_controller.h"
using namespace boost::beast::websocket;
diff --git a/src/components/hmi_message_handler/src/websocket_session.cc b/src/components/hmi_message_handler/src/websocket_session.cc
index 0327500a11..26f15695c9 100644
--- a/src/components/hmi_message_handler/src/websocket_session.cc
+++ b/src/components/hmi_message_handler/src/websocket_session.cc
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2018 Livio, Inc.
+Copyright (c) 2018 Livio, Inc.
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 eb9159f0b3..c7a50199b1 100644
--- a/src/components/include/application_manager/application_manager.h
+++ b/src/components/include/application_manager/application_manager.h
@@ -390,17 +390,34 @@ class ApplicationManager {
virtual void EndNaviServices(uint32_t app_id) = 0;
/* @brief Starts audio passthru process
+ * @deprecated Use BeginAudioPassThru(uint32_t app_id) instead
*
* @return true on success, false if passthru is already in process
*/
- virtual bool BeginAudioPassThrough() = 0;
+ DEPRECATED virtual bool BeginAudioPassThrough() = 0;
+
+ /**
+ * @brief Starts AudioPassThru process by given application
+ * @param app_id ID of the application which starts the process
+ * @return true if AudioPassThru can be started, false otherwise
+ */
+ virtual bool BeginAudioPassThru(uint32_t app_id) = 0;
/*
* @brief Finishes already started audio passthru process
+ * @deprecated Use EndAudioPassThru(uint32_t app_id) instead
*
* @return true on success, false if passthru is not active
*/
- virtual bool EndAudioPassThrough() = 0;
+ DEPRECATED virtual bool EndAudioPassThrough() = 0;
+
+ /**
+ * @brief Finishes already started AudioPassThru process by given application
+ * @param app_id ID of the application which started the process
+ * @return true if AudioPassThru process has been started with given
+ * application and thus it can be stopped, false otherwise
+ */
+ virtual bool EndAudioPassThru(uint32_t app_id) = 0;
virtual void ConnectToDevice(const std::string& device_mac) = 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 58edcb637a..452a1e6c39 100644
--- a/src/components/include/test/application_manager/mock_application_manager.h
+++ b/src/components/include/test/application_manager/mock_application_manager.h
@@ -161,8 +161,10 @@ class MockApplicationManager : public application_manager::ApplicationManager {
MOCK_METHOD0(GetNextHMICorrelationID, uint32_t());
MOCK_METHOD0(GenerateNewHMIAppID, uint32_t());
MOCK_METHOD1(EndNaviServices, void(uint32_t app_id));
- MOCK_METHOD0(BeginAudioPassThrough, bool());
- MOCK_METHOD0(EndAudioPassThrough, bool());
+ DEPRECATED MOCK_METHOD0(BeginAudioPassThrough, bool());
+ MOCK_METHOD1(BeginAudioPassThru, bool(uint32_t app_id));
+ DEPRECATED MOCK_METHOD0(EndAudioPassThrough, bool());
+ MOCK_METHOD1(EndAudioPassThru, bool(uint32_t app_id));
MOCK_METHOD1(ConnectToDevice, void(const std::string& device_mac));
MOCK_METHOD0(OnHMIStartedCooperation, void());
MOCK_CONST_METHOD0(IsHMICooperating, bool());
diff --git a/src/components/include/test/media_manager/mock_media_manager.h b/src/components/include/test/media_manager/mock_media_manager.h
index 9cd2a05fc0..b58cfab5d7 100644
--- a/src/components/include/test/media_manager/mock_media_manager.h
+++ b/src/components/include/test/media_manager/mock_media_manager.h
@@ -56,7 +56,7 @@ class MockMediaManager : public media_manager::MediaManager {
protocol_handler::ServiceType service_type));
MOCK_METHOD2(FramesProcessed,
void(int32_t application_key, int32_t frame_number));
- MOCK_CONST_METHOD0(settings, const MediaManagerSettings&());
+ MOCK_CONST_METHOD0(settings, const media_manager::MediaManagerSettings&());
};
} // namespace media_manager_test
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 2cd0d2b23b..433a7a6bca 100644
--- a/src/components/policy/policy_external/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_external/src/policy_manager_impl.cc
@@ -313,7 +313,10 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
utils::SharedPtr<policy_table::Table> policy_table_snapshot =
cache_->GenerateSnapshot();
if (!policy_table_snapshot) {
- LOG4CXX_ERROR(logger_, "Failed to create snapshot of policy table");
+ LOG4CXX_ERROR(
+ logger_,
+ "Failed to create snapshot of policy table, trying another exchange");
+ ForcePTExchange();
return false;
}
@@ -327,7 +330,10 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
// Replace current data with updated
if (!cache_->ApplyUpdate(*pt_update)) {
- LOG4CXX_WARN(logger_, "Unsuccessful save of updated policy table.");
+ LOG4CXX_WARN(
+ logger_,
+ "Unsuccessful save of updated policy table, trying another exchange");
+ ForcePTExchange();
return false;
}
@@ -588,8 +594,7 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
policy_table::FunctionalGroupings functional_groupings;
cache_->GetFunctionalGroupings(functional_groupings);
- policy_table::Strings app_groups =
- GetGroupsNames(app_group_permissions);
+ policy_table::Strings app_groups = GetGroupsNames(app_group_permissions);
// Undefined groups (without user consent) disallowed by default, since
// OnPermissionsChange notification has no "undefined" section
@@ -621,8 +626,7 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
}
const bool known_rpc = rpc_permissions.end() != rpc_permissions.find(rpc);
- LOG4CXX_DEBUG(logger_, "Is known rpc " <<
- (known_rpc ? "true" : "false") );
+ LOG4CXX_DEBUG(logger_, "Is known rpc " << (known_rpc ? "true" : "false"));
if (!known_rpc) {
// RPC not found in list == disallowed by backend
result.hmi_level_permitted = kRpcDisallowed;
@@ -644,7 +648,9 @@ void PolicyManagerImpl::CheckPermissions(const PTString& app_id,
rpc_permissions[rpc].hmi_permissions[kUserDisallowedKey].find(
hmi_level)) {
// RPC found in allowed == allowed by backend, but disallowed by user
- LOG4CXX_DEBUG(logger_, "RPC found in allowed == allowed by backend, but disallowed by user");
+ LOG4CXX_DEBUG(
+ logger_,
+ "RPC found in allowed == allowed by backend, but disallowed by user");
result.hmi_level_permitted = kRpcUserDisallowed;
} else {
LOG4CXX_DEBUG(logger_,
@@ -984,7 +990,6 @@ void PolicyManagerImpl::SetUserConsentForApp(
const PermissionConsent& permissions, const NotificationMode mode) {
LOG4CXX_AUTO_TRACE(logger_);
-
cache_->ResetCalculatedPermissions();
PermissionConsent verified_permissions =
EnsureCorrectPermissionConsent(permissions);
@@ -1569,8 +1574,7 @@ void PolicyManagerImpl::OnUpdateStarted() {
uint32_t update_timeout = TimeoutExchangeMSec();
LOG4CXX_DEBUG(logger_,
"Update timeout will be set to (milisec): " << update_timeout);
- send_on_update_sent_out_ =
- !wrong_ptu_update_received_ && !update_status_manager_.IsUpdatePending();
+ send_on_update_sent_out_ = !update_status_manager_.IsUpdatePending();
if (send_on_update_sent_out_) {
update_status_manager_.OnUpdateSentOut(update_timeout);
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 39b303cbb5..3e08147a4c 100644
--- a/src/components/policy/policy_regular/src/policy_manager_impl.cc
+++ b/src/components/policy/policy_regular/src/policy_manager_impl.cc
@@ -196,7 +196,10 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
utils::SharedPtr<policy_table::Table> policy_table_snapshot =
cache_->GenerateSnapshot();
if (!policy_table_snapshot) {
- LOG4CXX_ERROR(logger_, "Failed to create snapshot of policy table");
+ LOG4CXX_ERROR(
+ logger_,
+ "Failed to create snapshot of policy table, trying another exchange");
+ ForcePTExchange();
return false;
}
@@ -209,7 +212,10 @@ bool PolicyManagerImpl::LoadPT(const std::string& file,
// Replace current data with updated
if (!cache_->ApplyUpdate(*pt_update)) {
- LOG4CXX_WARN(logger_, "Unsuccessful save of updated policy table.");
+ LOG4CXX_WARN(
+ logger_,
+ "Unsuccessful save of updated policy table, trying another exchange");
+ ForcePTExchange();
return false;
}