From d42cfe8434ade15c75c07427f53a1cc70cd79c49 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Thu, 29 Mar 2018 10:56:18 -0400 Subject: Fix EventDispatcher crash by rejecting duplicate correlation_ids --- src/components/application_manager/src/request_controller.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc index 1b9bd7ffb9..a6d78f24de 100644 --- a/src/components/application_manager/src/request_controller.cc +++ b/src/components/application_manager/src/request_controller.cc @@ -474,7 +474,15 @@ void RequestController::Worker::threadMain() { RequestInfoPtr request_info_ptr = utils::MakeShared(request_ptr, timeout_in_mseconds); - request_controller_->waiting_for_response_.Add(request_info_ptr); + if (!request_controller_->waiting_for_response_.Add(request_info_ptr)) { + commands::CommandRequestImpl* cmd_request = + dynamic_cast(request_ptr.get()); + if (cmd_request != NULL) { + cmd_request->SendResponse( + false, mobile_apis::Result::INVALID_ID, "Duplicate correlation_id"); + } + continue; + } LOG4CXX_DEBUG(logger_, "timeout_in_mseconds " << timeout_in_mseconds); if (0 != timeout_in_mseconds) { -- cgit v1.2.1 From 546cd986780759dd5eee64998f99bc66099a3b32 Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Fri, 23 Feb 2018 17:54:43 +0200 Subject: Implement fully functional GetSystemTime feature Implemented fully working GetSystemTime feature Fixed UT in the security manager due to code changes Disable randomly failed test --- .../src/application_manager_impl.cc | 4 + .../basic_communication_get_system_time_request.cc | 49 ++++++ ...basic_communication_get_system_time_response.cc | 57 +++++++ .../hmi/on_system_time_ready_notification.cc | 56 +++++++ .../src/commands/hmi/request_to_hmi.cc | 4 +- .../application_manager/src/hmi_command_factory.cc | 18 +++ .../src/message_helper/message_helper.cc | 14 ++ .../src/policies/policy_handler.cc | 10 +- .../application_manager/src/smart_object_keys.cc | 17 ++- .../src/system_time/system_time_handler_impl.cc | 169 +++++++++++++++++++++ 10 files changed, 388 insertions(+), 10 deletions(-) create mode 100644 src/components/application_manager/src/commands/hmi/basic_communication_get_system_time_request.cc create mode 100644 src/components/application_manager/src/commands/hmi/basic_communication_get_system_time_response.cc create mode 100644 src/components/application_manager/src/commands/hmi/on_system_time_ready_notification.cc create mode 100644 src/components/application_manager/src/system_time/system_time_handler_impl.cc (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 248b54fee5..5aa72d77e5 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1691,6 +1691,10 @@ bool ApplicationManagerImpl::OnHandshakeDone( return false; } +void ApplicationManagerImpl::OnHandshakeFailed() { + LOG4CXX_AUTO_TRACE(logger_); +} + void ApplicationManagerImpl::OnCertificateUpdateRequired() { LOG4CXX_AUTO_TRACE(logger_); GetPolicyHandler().OnPTExchangeNeeded(); diff --git a/src/components/application_manager/src/commands/hmi/basic_communication_get_system_time_request.cc b/src/components/application_manager/src/commands/hmi/basic_communication_get_system_time_request.cc new file mode 100644 index 0000000000..215b0404a7 --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/basic_communication_get_system_time_request.cc @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribut wiion. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/commands/hmi/basic_communication_get_system_time_request.h" + +namespace application_manager { + +namespace commands { + +BasicCommunicationGetSystemTimeRequest::BasicCommunicationGetSystemTimeRequest( + const MessageSharedPtr& message, ApplicationManager& application_manager) + : RequestToHMI(message, application_manager) {} + +void BasicCommunicationGetSystemTimeRequest::onTimeOut() { + LOG4CXX_AUTO_TRACE(logger_); + application_manager_.protocol_handler().NotifyOnFailedHandshake(); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/basic_communication_get_system_time_response.cc b/src/components/application_manager/src/commands/hmi/basic_communication_get_system_time_response.cc new file mode 100644 index 0000000000..26dd115d1a --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/basic_communication_get_system_time_response.cc @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/commands/hmi/basic_communication_get_system_time_response.h" +#include "utils/logger.h" + +CREATE_LOGGERPTR_GLOBAL(logger_, "Commands") + +namespace application_manager { +namespace commands { + +BasicCommunicationGetSystemTimeResponse:: + BasicCommunicationGetSystemTimeResponse( + const MessageSharedPtr& message, + ApplicationManager& application_manager) + : ResponseFromHMI(message, application_manager) {} + +void BasicCommunicationGetSystemTimeResponse::Run() { + LOG4CXX_AUTO_TRACE(logger_); + + event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_GetSystemTime); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/on_system_time_ready_notification.cc b/src/components/application_manager/src/commands/hmi/on_system_time_ready_notification.cc new file mode 100644 index 0000000000..d2376e6dfe --- /dev/null +++ b/src/components/application_manager/src/commands/hmi/on_system_time_ready_notification.cc @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/commands/hmi/on_system_time_ready_notification.h" + +#include "application_manager/event_engine/event.h" +#include "interfaces/HMI_API.h" + +namespace application_manager { + +namespace commands { + +OnSystemTimeReadyNotification::OnSystemTimeReadyNotification( + const MessageSharedPtr& message, ApplicationManager& application_manager) + : NotificationFromHMI(message, application_manager) {} + +OnSystemTimeReadyNotification::~OnSystemTimeReadyNotification() {} + +void OnSystemTimeReadyNotification::Run() { + event_engine::Event event( + hmi_apis::FunctionID::BasicCommunication_OnSystemTimeReady); + event.set_smart_object(*message_); + event.raise(application_manager_.event_dispatcher()); +} + +} // namespace commands +} // namespace application_manager diff --git a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc index 6905e7cdef..23c020bca2 100644 --- a/src/components/application_manager/src/commands/hmi/request_to_hmi.cc +++ b/src/components/application_manager/src/commands/hmi/request_to_hmi.cc @@ -74,7 +74,9 @@ bool RequestToHMI::CleanUp() { return true; } -void RequestToHMI::Run() {} +void RequestToHMI::Run() { + SendRequest(); +} void RequestToHMI::SendRequest() { (*message_)[strings::params][strings::protocol_type] = hmi_protocol_type_; diff --git a/src/components/application_manager/src/hmi_command_factory.cc b/src/components/application_manager/src/hmi_command_factory.cc index a7f3ce7e6b..5ef8605999 100644 --- a/src/components/application_manager/src/hmi_command_factory.cc +++ b/src/components/application_manager/src/hmi_command_factory.cc @@ -224,6 +224,7 @@ #include "application_manager/commands/hmi/navi_get_way_points_request.h" #include "application_manager/commands/hmi/navi_get_way_points_response.h" #include "application_manager/commands/hmi/on_ready_notification.h" +#include "application_manager/commands/hmi/on_system_time_ready_notification.h" #include "application_manager/commands/hmi/on_device_chosen_notification.h" #include "application_manager/commands/hmi/on_file_removed_notification.h" #include "application_manager/commands/hmi/on_system_context_notification.h" @@ -269,6 +270,8 @@ #include "application_manager/commands/hmi/on_system_error_notification.h" #include "application_manager/commands/hmi/basic_communication_system_request.h" #include "application_manager/commands/hmi/basic_communication_system_response.h" +#include "application_manager/commands/hmi/basic_communication_get_system_time_request.h" +#include "application_manager/commands/hmi/basic_communication_get_system_time_response.h" #include "application_manager/commands/hmi/basic_communication_on_awake_sdl.h" #include "application_manager/commands/hmi/sdl_policy_update.h" #include "application_manager/commands/hmi/sdl_policy_update_response.h" @@ -1285,6 +1288,11 @@ CommandSharedPtr HMICommandFactory::CreateCommand( new commands::OnReadyNotification(message, application_manager)); break; } + case hmi_apis::FunctionID::BasicCommunication_OnSystemTimeReady: { + command.reset(new commands::OnSystemTimeReadyNotification( + message, application_manager)); + break; + } case hmi_apis::FunctionID::BasicCommunication_OnDeviceChosen: { command.reset(new commands::OnDeviceChosenNotification( message, application_manager)); @@ -2221,6 +2229,16 @@ CommandSharedPtr HMICommandFactory::CreateCommand( } break; } + case hmi_apis::FunctionID::BasicCommunication_GetSystemTime: { + if (is_response) { + command.reset(new commands::BasicCommunicationGetSystemTimeResponse( + message, application_manager)); + } else { + command.reset(new commands::BasicCommunicationGetSystemTimeRequest( + message, application_manager)); + } + break; + } case hmi_apis::FunctionID::Navigation_SendLocation: { if (is_response) { command.reset(new commands::NaviSendLocationResponse( 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 6a908c4ebc..9a10c908f1 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -365,6 +365,20 @@ void MessageHelper::SendDecryptCertificateToHMI(const std::string& file_name, app_mngr.ManageHMICommand(message); } +void MessageHelper::SendGetSystemTimeRequest(const uint32_t correlation_id, + ApplicationManager& app_mngr) { + using namespace smart_objects; + SmartObjectSPtr message = + CreateMessageForHMI(hmi_apis::messageType::request, correlation_id); + + DCHECK(message); + + (*message)[strings::params][strings::function_id] = + hmi_apis::FunctionID::BasicCommunication_GetSystemTime; + + app_mngr.ManageHMICommand(message); +} + void MessageHelper::SendHashUpdateNotification(const uint32_t app_id, ApplicationManager& app_mngr) { LOG4CXX_AUTO_TRACE(logger_); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index bbf391a9f1..98fb6bae65 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1765,11 +1765,11 @@ void PolicyHandler::OnCertificateDecrypted(bool is_succeeded) { void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(listeners_lock_); - HandlersCollection::const_iterator it = listeners_.begin(); - for (; it != listeners_.end(); ++it) { - PolicyHandlerObserver* observer = *it; - observer->OnCertificateUpdated(certificate_data); - } + std::for_each( + listeners_.begin(), + listeners_.end(), + std::bind2nd(std::mem_fun(&PolicyHandlerObserver::OnCertificateUpdated), + certificate_data)); } #endif // EXTERNAL_PROPRIETARY_MODE diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index c3aba90dd5..888943d4d6 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -351,7 +351,7 @@ const char* instance_follow_redirect = "InstanceFollowRedirect"; const char* charset = "charset"; const char* content_lenght = "Content_Lenght"; const char* GET = "GET"; -} // http_request +} // namespace http_request namespace mobile_notification { const char* state = "state"; @@ -364,7 +364,17 @@ const char* kFull = "FULL"; const char* kLimited = "LIMITED"; const char* kBackground = "BACKGROUND"; const char* kNone = "NONE"; -} +} // namespace hmi_levels + +namespace time_keys { +const char* millisecond = "millisecond"; +const char* second = "second"; +const char* minute = "minute"; +const char* hour = "hour"; +const char* day = "day"; +const char* month = "month"; +const char* year = "year"; +} // namespace time_keys namespace hmi_request { const char* parent_id = "parentID"; @@ -436,7 +446,7 @@ const char* num_custom_presets_available = "numCustomPresetsAvailable"; const char* urls = "urls"; const char* policy_app_id = "policyAppID"; const char* enabled = "enabled"; - +const char* system_time = "systemTime"; } // namespace hmi_response namespace hmi_notification { @@ -451,7 +461,6 @@ const char* policyfile = "policyfile"; const char* is_active = "isActive"; const char* is_deactivated = "isDeactivated"; const char* event_name = "eventName"; - } // namespace hmi_notification } // namespace application_manager diff --git a/src/components/application_manager/src/system_time/system_time_handler_impl.cc b/src/components/application_manager/src/system_time/system_time_handler_impl.cc new file mode 100644 index 0000000000..a91fb16197 --- /dev/null +++ b/src/components/application_manager/src/system_time/system_time_handler_impl.cc @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2018, Ford Motor Company + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of the Ford Motor Company nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "application_manager/system_time/system_time_handler_impl.h" + +#include + +#include "application_manager/message_helper.h" +#include "application_manager/smart_object_keys.h" +#include "interfaces/HMI_API.h" +#include "utils/logger.h" + +namespace application_manager { + +SystemTimeHandlerImpl::SystemTimeHandlerImpl( + ApplicationManager& application_manager) + : event_engine::EventObserver(application_manager.event_dispatcher()) + , utc_time_can_be_received_(false) + , schedule_request_(false) + , system_time_listener_(NULL) + , app_manager_(application_manager) { + LOG4CXX_AUTO_TRACE(logger_); + subscribe_on_event( + hmi_apis::FunctionID::BasicCommunication_OnSystemTimeReady); +} + +SystemTimeHandlerImpl::~SystemTimeHandlerImpl() { + LOG4CXX_AUTO_TRACE(logger_); + unsubscribe_from_all_events(); +} + +void SystemTimeHandlerImpl::DoSystemTimeQuery() { + LOG4CXX_AUTO_TRACE(logger_); + using namespace application_manager; + + sync_primitives::AutoLock lock(state_lock_); + if (!utc_time_can_be_received_) { + LOG4CXX_INFO(logger_, + "Navi module is not yet ready." + << "Will process request once it became ready."); + schedule_request_ = true; + return; + } + SendTimeRequest(); +} + +void SystemTimeHandlerImpl::DoSubscribe(utils::SystemTimeListener* listener) { + LOG4CXX_AUTO_TRACE(logger_); + DCHECK(listener); + sync_primitives::AutoLock lock(system_time_listener_lock_); + system_time_listener_ = listener; +} + +void SystemTimeHandlerImpl::DoUnsubscribe(utils::SystemTimeListener* listener) { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(system_time_listener_lock_); + system_time_listener_ = NULL; +} + +time_t SystemTimeHandlerImpl::FetchSystemTime() { + LOG4CXX_AUTO_TRACE(logger_); + return last_time_; +} + +bool SystemTimeHandlerImpl::utc_time_can_be_received() const { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(state_lock_); + return utc_time_can_be_received_; +} + +void SystemTimeHandlerImpl::SendTimeRequest() { + LOG4CXX_AUTO_TRACE(logger_); + using namespace application_manager; + uint32_t correlation_id = app_manager_.GetNextHMICorrelationID(); + subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_GetSystemTime, + correlation_id); + MessageHelper::SendGetSystemTimeRequest(correlation_id, app_manager_); +} + +void SystemTimeHandlerImpl::on_event( + const application_manager::event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + using namespace application_manager; + using namespace hmi_apis::FunctionID; + switch (event.id()) { + case BasicCommunication_OnSystemTimeReady: + ProcessSystemTimeReadyNotification(); + break; + case BasicCommunication_GetSystemTime: + ProcessSystemTimeResponse(event); + break; + default: + LOG4CXX_ERROR(logger_, "Unknown Event received"); + break; + } +} + +void SystemTimeHandlerImpl::ProcessSystemTimeReadyNotification() { + LOG4CXX_AUTO_TRACE(logger_); + sync_primitives::AutoLock lock(state_lock_); + utc_time_can_be_received_ = true; + if (schedule_request_) { + SendTimeRequest(); + schedule_request_ = false; + } + unsubscribe_from_event( + hmi_apis::FunctionID::BasicCommunication_OnSystemTimeReady); +} + +void SystemTimeHandlerImpl::ProcessSystemTimeResponse( + const application_manager::event_engine::Event& event) { + LOG4CXX_AUTO_TRACE(logger_); + const smart_objects::SmartObject& message = event.smart_object(); + const smart_objects::SmartObject& system_time_so = + message[strings::msg_params][hmi_response::system_time]; + + struct tm system_time; + memset(&system_time, 0, sizeof(struct tm)); + + system_time.tm_sec = system_time_so[time_keys::second].asInt(); + system_time.tm_min = system_time_so[time_keys::minute].asInt(); + // According to tm specification of tm type hour should be decreased by 1 + system_time.tm_hour = system_time_so[time_keys::hour].asInt() - 1; + system_time.tm_mday = system_time_so[time_keys::day].asInt(); + // According to tm specification of tm type mon should be decreased by 1 + system_time.tm_mon = system_time_so[time_keys::month].asInt() - 1; + // According to tm specification of tm type + // tm_year - number of years since 1900 + system_time.tm_year = system_time_so[time_keys::year].asInt() - 1900; + + // Normalize and convert time from 'tm' format to 'time_t' + last_time_ = mktime(&system_time); + + sync_primitives::AutoLock lock(system_time_listener_lock_); + if (system_time_listener_) { + system_time_listener_->OnSystemTimeArrived(last_time_); + } +} + +} // namespace application_manager -- cgit v1.2.1 From 28d80dadabf8d4697b3d438d25adf22e8a0b6430 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 25 Apr 2018 15:33:55 -0400 Subject: Implementation of color schemes --- .../src/application_data_impl.cc | 42 +++++++++++++++++++++- .../mobile/register_app_interface_request.cc | 20 +++++++++++ .../src/message_helper/message_helper.cc | 12 +++++++ .../application_manager/src/smart_object_keys.cc | 8 +++++ 4 files changed, 81 insertions(+), 1 deletion(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_data_impl.cc b/src/components/application_manager/src/application_data_impl.cc index a81540708c..cecd8d2d6c 100644 --- a/src/components/application_manager/src/application_data_impl.cc +++ b/src/components/application_manager/src/application_data_impl.cc @@ -45,7 +45,9 @@ InitialApplicationDataImpl::InitialApplicationDataImpl() , tts_name_(NULL) , ngn_media_screen_name_(NULL) , language_(mobile_api::Language::INVALID_ENUM) - , ui_language_(mobile_api::Language::INVALID_ENUM) {} + , ui_language_(mobile_api::Language::INVALID_ENUM) + , day_color_scheme_(NULL) + , night_color_scheme_(NULL) {} InitialApplicationDataImpl::~InitialApplicationDataImpl() { if (app_types_) { @@ -67,6 +69,16 @@ InitialApplicationDataImpl::~InitialApplicationDataImpl() { delete ngn_media_screen_name_; ngn_media_screen_name_ = NULL; } + + if (day_color_scheme_) { + delete day_color_scheme_; + day_color_scheme_ = NULL; + } + + if (night_color_scheme_) { + delete night_color_scheme_; + night_color_scheme_ = NULL; + } } const smart_objects::SmartObject* InitialApplicationDataImpl::app_types() @@ -102,6 +114,16 @@ const mobile_api::Language::eType& InitialApplicationDataImpl::ui_language() return ui_language_; } +const smart_objects::SmartObject* +InitialApplicationDataImpl::day_color_scheme() const { + return day_color_scheme_; +} + +const smart_objects::SmartObject* +InitialApplicationDataImpl::night_color_scheme() const { + return night_color_scheme_; +} + void InitialApplicationDataImpl::set_app_types( const smart_objects::SmartObject& app_types) { if (app_types_) { @@ -162,6 +184,24 @@ InitialApplicationDataImpl::perform_interaction_layout() const { return perform_interaction_layout_; } +void InitialApplicationDataImpl::set_day_color_scheme( + const smart_objects::SmartObject& color_scheme) { + if (day_color_scheme_) { + delete day_color_scheme_; + } + + day_color_scheme_ = new smart_objects::SmartObject(color_scheme); +} + +void InitialApplicationDataImpl::set_night_color_scheme( + const smart_objects::SmartObject& color_scheme) { + if (night_color_scheme_) { + delete night_color_scheme_; + } + + night_color_scheme_ = new smart_objects::SmartObject(color_scheme); +} + DynamicApplicationDataImpl::DynamicApplicationDataImpl() : help_prompt_(NULL) , timeout_prompt_(NULL) 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 a3a30ddb20..c0cbe80ae4 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 @@ -348,6 +348,14 @@ void RegisterAppInterfaceRequest::Run() { } } + if (msg_params.keyExists(strings::day_color_scheme)) { + application->set_day_color_scheme(msg_params[strings::day_color_scheme]); + } + + if (msg_params.keyExists(strings::night_color_scheme)) { + application->set_night_color_scheme(msg_params[strings::night_color_scheme]); + } + // Add device to policy table and set device info, if any policy::DeviceParams dev_params; if (-1 == @@ -884,6 +892,18 @@ void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( device_info[strings::transport_type] = application_manager_.GetDeviceTransportType(transport_type); + const smart_objects::SmartObject* day_color_scheme = + application_impl.day_color_scheme(); + if (day_color_scheme) { + application[strings::day_color_scheme] = *day_color_scheme; + } + + const smart_objects::SmartObject* night_color_scheme = + application_impl.night_color_scheme(); + if (night_color_scheme) { + application[strings::night_color_scheme] = *night_color_scheme; + } + DCHECK(application_manager_.ManageHMICommand(notification)); } 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 6a908c4ebc..41138784c2 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -1677,6 +1677,10 @@ bool MessageHelper::CreateHMIApplicationStruct( const smart_objects::SmartObject* app_types = app->app_types(); const smart_objects::SmartObject* ngn_media_screen_name = app->ngn_media_screen_name(); + const smart_objects::SmartObject* day_color_scheme = + app->day_color_scheme(); + const smart_objects::SmartObject* night_color_scheme = + app->night_color_scheme(); std::string device_name; std::string mac_address; std::string transport_type; @@ -1714,6 +1718,14 @@ bool MessageHelper::CreateHMIApplicationStruct( message[strings::app_type] = *app_types; } + if (day_color_scheme) { + message[strings::day_color_scheme] = *day_color_scheme; + } + + if (night_color_scheme) { + message[strings::night_color_scheme] = *night_color_scheme; + } + message[strings::device_info] = smart_objects::SmartObject(smart_objects::SmartType_Map); message[strings::device_info][strings::name] = device_name; diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index c3aba90dd5..88ec5986f4 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -142,6 +142,14 @@ const char* navigation_capability = "navigationCapability"; const char* phone_capability = "phoneCapability"; const char* video_streaming_capability = "videoStreamingCapability"; const char* rc_capability = "remoteControlCapability"; +const char* day_color_scheme = "dayColorScheme"; +const char* night_color_scheme = "nightColorScheme"; +const char* primary_color = "primaryColor"; +const char* secondary_color = "secondaryColor"; +const char* background_color = "backgroundColor"; +const char* red = "red"; +const char* green = "green"; +const char* blue = "blue"; // PutFile const char* sync_file_name = "syncFileName"; -- cgit v1.2.1 From ffab62e1f509d5aeb44436a705146c1ee4f5f77a Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Wed, 25 Apr 2018 15:17:36 -0400 Subject: Add `engineOilLife` vehicle data --- .../application_manager/src/message_helper/message_helper.cc | 3 ++- src/components/application_manager/src/smart_object_keys.cc | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/components/application_manager/src') 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 6a908c4ebc..6938677ed0 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -217,7 +217,8 @@ std::pair Date: Tue, 1 May 2018 11:04:33 -0400 Subject: Move color scheme to Dynamic Application Data & Add Set Display layout support --- .../src/application_data_impl.cc | 82 +++++++++++----------- .../commands/mobile/set_display_layout_request.cc | 13 +++- 2 files changed, 53 insertions(+), 42 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_data_impl.cc b/src/components/application_manager/src/application_data_impl.cc index cecd8d2d6c..a5c39455ba 100644 --- a/src/components/application_manager/src/application_data_impl.cc +++ b/src/components/application_manager/src/application_data_impl.cc @@ -45,9 +45,7 @@ InitialApplicationDataImpl::InitialApplicationDataImpl() , tts_name_(NULL) , ngn_media_screen_name_(NULL) , language_(mobile_api::Language::INVALID_ENUM) - , ui_language_(mobile_api::Language::INVALID_ENUM) - , day_color_scheme_(NULL) - , night_color_scheme_(NULL) {} + , ui_language_(mobile_api::Language::INVALID_ENUM) {} InitialApplicationDataImpl::~InitialApplicationDataImpl() { if (app_types_) { @@ -69,16 +67,6 @@ InitialApplicationDataImpl::~InitialApplicationDataImpl() { delete ngn_media_screen_name_; ngn_media_screen_name_ = NULL; } - - if (day_color_scheme_) { - delete day_color_scheme_; - day_color_scheme_ = NULL; - } - - if (night_color_scheme_) { - delete night_color_scheme_; - night_color_scheme_ = NULL; - } } const smart_objects::SmartObject* InitialApplicationDataImpl::app_types() @@ -114,16 +102,6 @@ const mobile_api::Language::eType& InitialApplicationDataImpl::ui_language() return ui_language_; } -const smart_objects::SmartObject* -InitialApplicationDataImpl::day_color_scheme() const { - return day_color_scheme_; -} - -const smart_objects::SmartObject* -InitialApplicationDataImpl::night_color_scheme() const { - return night_color_scheme_; -} - void InitialApplicationDataImpl::set_app_types( const smart_objects::SmartObject& app_types) { if (app_types_) { @@ -184,24 +162,6 @@ InitialApplicationDataImpl::perform_interaction_layout() const { return perform_interaction_layout_; } -void InitialApplicationDataImpl::set_day_color_scheme( - const smart_objects::SmartObject& color_scheme) { - if (day_color_scheme_) { - delete day_color_scheme_; - } - - day_color_scheme_ = new smart_objects::SmartObject(color_scheme); -} - -void InitialApplicationDataImpl::set_night_color_scheme( - const smart_objects::SmartObject& color_scheme) { - if (night_color_scheme_) { - delete night_color_scheme_; - } - - night_color_scheme_ = new smart_objects::SmartObject(color_scheme); -} - DynamicApplicationDataImpl::DynamicApplicationDataImpl() : help_prompt_(NULL) , timeout_prompt_(NULL) @@ -213,6 +173,8 @@ DynamicApplicationDataImpl::DynamicApplicationDataImpl() , menu_title_(NULL) , menu_icon_(NULL) , tbt_show_command_(NULL) + , day_color_scheme_(NULL) + , night_color_scheme_(NULL) , commands_() , commands_lock_(true) , sub_menu_() @@ -254,6 +216,16 @@ DynamicApplicationDataImpl::~DynamicApplicationDataImpl() { tbt_show_command_ = NULL; } + if (day_color_scheme_) { + delete day_color_scheme_; + day_color_scheme_ = NULL; + } + + if (night_color_scheme_) { + delete night_color_scheme_; + night_color_scheme_ = NULL; + } + for (CommandsMap::iterator command_it = commands_.begin(); commands_.end() != command_it; ++command_it) { @@ -330,6 +302,16 @@ const smart_objects::SmartObject* DynamicApplicationDataImpl::menu_icon() return menu_icon_; } +const smart_objects::SmartObject* +DynamicApplicationDataImpl::day_color_scheme() const { + return day_color_scheme_; +} + +const smart_objects::SmartObject* +DynamicApplicationDataImpl::night_color_scheme() const { + return night_color_scheme_; +} + void DynamicApplicationDataImpl::load_global_properties( const smart_objects::SmartObject& properties_so) { SetGlobalProperties(properties_so.getElement(strings::vr_help_title), @@ -445,6 +427,24 @@ void DynamicApplicationDataImpl::set_menu_icon( menu_icon_ = new smart_objects::SmartObject(menu_icon); } +void DynamicApplicationDataImpl::set_day_color_scheme( + const smart_objects::SmartObject& color_scheme) { + if (day_color_scheme_) { + delete day_color_scheme_; + } + + day_color_scheme_ = new smart_objects::SmartObject(color_scheme); +} + +void DynamicApplicationDataImpl::set_night_color_scheme( + const smart_objects::SmartObject& color_scheme) { + if (night_color_scheme_) { + delete night_color_scheme_; + } + + night_color_scheme_ = new smart_objects::SmartObject(color_scheme); +} + void DynamicApplicationDataImpl::SetGlobalProperties( const smart_objects::SmartObject& param, void (DynamicApplicationData::*callback)( 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 38b62ce731..993e094647 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 @@ -48,7 +48,7 @@ SetDisplayLayoutRequest::~SetDisplayLayoutRequest() {} void SetDisplayLayoutRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - ApplicationConstSharedPtr app = + ApplicationSharedPtr app = application_manager_.application(connection_key()); if (!app) { @@ -57,6 +57,17 @@ void SetDisplayLayoutRequest::Run() { return; } + const smart_objects::SmartObject& msg_params = + (*message_)[strings::msg_params]; + + if (msg_params.keyExists(strings::day_color_scheme)) { + app->set_day_color_scheme(msg_params[strings::day_color_scheme]); + } + + if (msg_params.keyExists(strings::night_color_scheme)) { + app->set_night_color_scheme(msg_params[strings::night_color_scheme]); + } + (*message_)[strings::msg_params][strings::app_id] = app->app_id(); StartAwaitForInterface(HmiInterfaces::HMI_INTERFACE_UI); SendHMIRequest(hmi_apis::FunctionID::UI_SetDisplayLayout, -- cgit v1.2.1 From 47d09114d7a71c871b1b697c8f807de338995e0f Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 2 May 2018 11:41:29 -0400 Subject: Upadte Color Via Set Display Layout and add Reject Logic --- .../src/application_data_impl.cc | 9 ++++ .../commands/mobile/set_display_layout_request.cc | 48 +++++++++++++++++++++- .../application_manager/src/smart_object_keys.cc | 1 + 3 files changed, 56 insertions(+), 2 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_data_impl.cc b/src/components/application_manager/src/application_data_impl.cc index a5c39455ba..5e31995b7d 100644 --- a/src/components/application_manager/src/application_data_impl.cc +++ b/src/components/application_manager/src/application_data_impl.cc @@ -175,6 +175,7 @@ DynamicApplicationDataImpl::DynamicApplicationDataImpl() , tbt_show_command_(NULL) , day_color_scheme_(NULL) , night_color_scheme_(NULL) + , display_layout_("") , commands_() , commands_lock_(true) , sub_menu_() @@ -312,6 +313,10 @@ DynamicApplicationDataImpl::night_color_scheme() const { return night_color_scheme_; } +const std::string& DynamicApplicationDataImpl::display_layout() const { + return display_layout_; +} + void DynamicApplicationDataImpl::load_global_properties( const smart_objects::SmartObject& properties_so) { SetGlobalProperties(properties_so.getElement(strings::vr_help_title), @@ -445,6 +450,10 @@ void DynamicApplicationDataImpl::set_night_color_scheme( night_color_scheme_ = new smart_objects::SmartObject(color_scheme); } +void DynamicApplicationDataImpl::set_display_layout(const std::string& layout) { + display_layout_ = layout; +} + void DynamicApplicationDataImpl::SetGlobalProperties( const smart_objects::SmartObject& param, void (DynamicApplicationData::*callback)( 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 993e094647..e80912f2d9 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 @@ -60,12 +60,56 @@ void SetDisplayLayoutRequest::Run() { const smart_objects::SmartObject& msg_params = (*message_)[strings::msg_params]; + std::string old_layout = app->display_layout(); + std::string new_layout = ""; + bool allow_color_change = true; + + if (msg_params.keyExists(strings::display_layout)) { + new_layout = msg_params[strings::display_layout].asString(); + } + + if(new_layout != old_layout && !new_layout.empty()) { // Template switched, allow any color change + LOG4CXX_DEBUG(logger_, "SetDisplayLayoutRequest New Layout: " << new_layout); + app->set_display_layout(new_layout); + } else { + LOG4CXX_DEBUG(logger_, "SetDisplayLayoutRequest No Layout Change"); + // 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)) { + if(!(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"); + allow_color_change = false; + } + + } + + if ((msg_params.keyExists(strings::night_color_scheme) && app->night_color_scheme() != NULL)) { + if(!(msg_params[strings::night_color_scheme] == *(app->night_color_scheme())) ) { + //Color scheme param exists and has been previously set, do not allow color change + LOG4CXX_DEBUG(logger_, "Reject Night Color Scheme Change"); + allow_color_change = false; + } + } + } + if (msg_params.keyExists(strings::day_color_scheme)) { - app->set_day_color_scheme(msg_params[strings::day_color_scheme]); + if(allow_color_change) { + LOG4CXX_DEBUG(logger_, "Allow Day Color Scheme Change"); + app->set_day_color_scheme(msg_params[strings::day_color_scheme]); + } } if (msg_params.keyExists(strings::night_color_scheme)) { - app->set_night_color_scheme(msg_params[strings::night_color_scheme]); + if(allow_color_change) { + LOG4CXX_DEBUG(logger_, "Allow Night Color Scheme Change"); + app->set_night_color_scheme(msg_params[strings::night_color_scheme]); + } + } + + if (!allow_color_change) { + SendResponse(false, mobile_apis::Result::REJECTED); + return; } (*message_)[strings::msg_params][strings::app_id] = app->app_id(); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 88ec5986f4..788f8d28fc 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -150,6 +150,7 @@ const char* background_color = "backgroundColor"; const char* red = "red"; const char* green = "green"; const char* blue = "blue"; +const char* display_layout = "displayLayout"; // PutFile const char* sync_file_name = "syncFileName"; -- cgit v1.2.1 From 37de8947449d951d7a495b12a0ce510e52481d19 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 2 May 2018 11:43:10 -0400 Subject: Fix Style --- .../src/application_data_impl.cc | 8 ++--- .../mobile/register_app_interface_request.cc | 3 +- .../commands/mobile/set_display_layout_request.cc | 42 ++++++++++++---------- .../src/message_helper/message_helper.cc | 7 ++-- 4 files changed, 33 insertions(+), 27 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_data_impl.cc b/src/components/application_manager/src/application_data_impl.cc index 5e31995b7d..226c83dbf6 100644 --- a/src/components/application_manager/src/application_data_impl.cc +++ b/src/components/application_manager/src/application_data_impl.cc @@ -303,8 +303,8 @@ const smart_objects::SmartObject* DynamicApplicationDataImpl::menu_icon() return menu_icon_; } -const smart_objects::SmartObject* -DynamicApplicationDataImpl::day_color_scheme() const { +const smart_objects::SmartObject* DynamicApplicationDataImpl::day_color_scheme() + const { return day_color_scheme_; } @@ -433,7 +433,7 @@ void DynamicApplicationDataImpl::set_menu_icon( } void DynamicApplicationDataImpl::set_day_color_scheme( - const smart_objects::SmartObject& color_scheme) { + const smart_objects::SmartObject& color_scheme) { if (day_color_scheme_) { delete day_color_scheme_; } @@ -442,7 +442,7 @@ void DynamicApplicationDataImpl::set_day_color_scheme( } void DynamicApplicationDataImpl::set_night_color_scheme( - const smart_objects::SmartObject& color_scheme) { + const smart_objects::SmartObject& color_scheme) { if (night_color_scheme_) { delete night_color_scheme_; } 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 c0cbe80ae4..c799d68609 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 @@ -353,7 +353,8 @@ void RegisterAppInterfaceRequest::Run() { } if (msg_params.keyExists(strings::night_color_scheme)) { - application->set_night_color_scheme(msg_params[strings::night_color_scheme]); + application->set_night_color_scheme( + msg_params[strings::night_color_scheme]); } // Add device to policy table and set device info, if any 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 e80912f2d9..ba6bba8054 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 @@ -48,8 +48,7 @@ SetDisplayLayoutRequest::~SetDisplayLayoutRequest() {} void SetDisplayLayoutRequest::Run() { LOG4CXX_AUTO_TRACE(logger_); - ApplicationSharedPtr app = - application_manager_.application(connection_key()); + ApplicationSharedPtr app = application_manager_.application(connection_key()); if (!app) { LOG4CXX_ERROR(logger_, "Application is not registered"); @@ -58,7 +57,7 @@ void SetDisplayLayoutRequest::Run() { } const smart_objects::SmartObject& msg_params = - (*message_)[strings::msg_params]; + (*message_)[strings::msg_params]; std::string old_layout = app->display_layout(); std::string new_layout = ""; @@ -68,25 +67,32 @@ void SetDisplayLayoutRequest::Run() { new_layout = msg_params[strings::display_layout].asString(); } - if(new_layout != old_layout && !new_layout.empty()) { // Template switched, allow any color change - LOG4CXX_DEBUG(logger_, "SetDisplayLayoutRequest New Layout: " << new_layout); + if (new_layout != old_layout && + !new_layout.empty()) { // Template switched, allow any color change + LOG4CXX_DEBUG(logger_, + "SetDisplayLayoutRequest New Layout: " << new_layout); app->set_display_layout(new_layout); - } else { + } else { LOG4CXX_DEBUG(logger_, "SetDisplayLayoutRequest No Layout Change"); // 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)) { - if(!(msg_params[strings::day_color_scheme] == *(app->day_color_scheme())) ) { - //Color scheme param exists and has been previously set, do not allow color change + if ((msg_params.keyExists(strings::day_color_scheme) && + app->day_color_scheme() != NULL)) { + if (!(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"); - allow_color_change = false; + allow_color_change = false; } - } - if ((msg_params.keyExists(strings::night_color_scheme) && app->night_color_scheme() != NULL)) { - if(!(msg_params[strings::night_color_scheme] == *(app->night_color_scheme())) ) { - //Color scheme param exists and has been previously set, do not allow color change + if ((msg_params.keyExists(strings::night_color_scheme) && + app->night_color_scheme() != NULL)) { + if (!(msg_params[strings::night_color_scheme] == + *(app->night_color_scheme()))) { + // Color scheme param exists and has been previously set, do not allow + // color change LOG4CXX_DEBUG(logger_, "Reject Night Color Scheme Change"); allow_color_change = false; } @@ -94,17 +100,17 @@ void SetDisplayLayoutRequest::Run() { } if (msg_params.keyExists(strings::day_color_scheme)) { - if(allow_color_change) { + if (allow_color_change) { LOG4CXX_DEBUG(logger_, "Allow Day Color Scheme Change"); app->set_day_color_scheme(msg_params[strings::day_color_scheme]); - } + } } if (msg_params.keyExists(strings::night_color_scheme)) { - if(allow_color_change) { + if (allow_color_change) { LOG4CXX_DEBUG(logger_, "Allow Night Color Scheme Change"); app->set_night_color_scheme(msg_params[strings::night_color_scheme]); - } + } } if (!allow_color_change) { 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 41138784c2..80141aa7dc 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -1677,8 +1677,7 @@ bool MessageHelper::CreateHMIApplicationStruct( const smart_objects::SmartObject* app_types = app->app_types(); const smart_objects::SmartObject* ngn_media_screen_name = app->ngn_media_screen_name(); - const smart_objects::SmartObject* day_color_scheme = - app->day_color_scheme(); + const smart_objects::SmartObject* day_color_scheme = app->day_color_scheme(); const smart_objects::SmartObject* night_color_scheme = app->night_color_scheme(); std::string device_name; @@ -1718,11 +1717,11 @@ bool MessageHelper::CreateHMIApplicationStruct( message[strings::app_type] = *app_types; } - if (day_color_scheme) { + if (day_color_scheme) { message[strings::day_color_scheme] = *day_color_scheme; } - if (night_color_scheme) { + if (night_color_scheme) { message[strings::night_color_scheme] = *night_color_scheme; } -- cgit v1.2.1 From 1e9d9b20d7dd1599b21b3bebe75d993165745be0 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Tue, 24 Apr 2018 15:35:43 -0400 Subject: Add secondaryGraphic to ImageFieldName enum --- src/components/application_manager/src/hmi_capabilities_impl.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index e39b728155..278e4761db 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -281,6 +281,9 @@ void InitCapabilities() { std::string("appIcon"), hmi_apis::Common_ImageFieldName::appIcon)); image_field_name_enum.insert(std::make_pair( std::string("graphic"), hmi_apis::Common_ImageFieldName::graphic)); + image_field_name_enum.insert( + std::make_pair(std::string("secondaryGraphic"), + hmi_apis::Common_ImageFieldName::secondaryGraphic)); image_field_name_enum.insert( std::make_pair(std::string("showConstantTBTIcon"), hmi_apis::Common_ImageFieldName::showConstantTBTIcon)); -- cgit v1.2.1 From ff50d25bd55d38b07ea2ca910dc4fd6f39b5a939 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 3 May 2018 11:10:09 -0400 Subject: Implement Fuel Range Vehicle Data Parameter --- src/components/application_manager/src/message_helper/message_helper.cc | 2 ++ src/components/application_manager/src/smart_object_keys.cc | 1 + 2 files changed, 3 insertions(+) (limited to 'src/components/application_manager/src') 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 6a908c4ebc..229c49d63d 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -175,6 +175,8 @@ std::pair Date: Thu, 3 May 2018 15:15:08 -0400 Subject: Style & Review Comments --- .../commands/mobile/set_display_layout_request.cc | 54 +++++++++------------- 1 file changed, 22 insertions(+), 32 deletions(-) (limited to 'src/components/application_manager/src') 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 ba6bba8054..648a531e92 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 @@ -61,7 +61,6 @@ void SetDisplayLayoutRequest::Run() { std::string old_layout = app->display_layout(); std::string new_layout = ""; - bool allow_color_change = true; if (msg_params.keyExists(strings::display_layout)) { new_layout = msg_params[strings::display_layout].asString(); @@ -76,46 +75,37 @@ void SetDisplayLayoutRequest::Run() { LOG4CXX_DEBUG(logger_, "SetDisplayLayoutRequest No Layout Change"); // 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)) { - if (!(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"); - allow_color_change = false; - } + if (msg_params.keyExists(strings::day_color_scheme) && + app->day_color_scheme() != NULL && + !(msg_params[strings::day_color_scheme] == + *(app->day_color_scheme()))) { + // Color scheme param exists and has been previously set, do not allow + // color change + LOG4CXX_DEBUG(logger_, "Reject Day Color Scheme Change"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; } - if ((msg_params.keyExists(strings::night_color_scheme) && - app->night_color_scheme() != NULL)) { - if (!(msg_params[strings::night_color_scheme] == - *(app->night_color_scheme()))) { - // Color scheme param exists and has been previously set, do not allow - // color change - LOG4CXX_DEBUG(logger_, "Reject Night Color Scheme Change"); - allow_color_change = false; - } + if (msg_params.keyExists(strings::night_color_scheme) && + app->night_color_scheme() != NULL && + !(msg_params[strings::night_color_scheme] == + *(app->night_color_scheme()))) { + // Color scheme param exists and has been previously set, do not allow + // color change + LOG4CXX_DEBUG(logger_, "Reject Night Color Scheme Change"); + SendResponse(false, mobile_apis::Result::REJECTED); + return; } } if (msg_params.keyExists(strings::day_color_scheme)) { - if (allow_color_change) { - LOG4CXX_DEBUG(logger_, "Allow Day Color Scheme Change"); - app->set_day_color_scheme(msg_params[strings::day_color_scheme]); - } + LOG4CXX_DEBUG(logger_, "Allow Day Color Scheme Change"); + app->set_day_color_scheme(msg_params[strings::day_color_scheme]); } if (msg_params.keyExists(strings::night_color_scheme)) { - if (allow_color_change) { - LOG4CXX_DEBUG(logger_, "Allow Night Color Scheme Change"); - app->set_night_color_scheme(msg_params[strings::night_color_scheme]); - } - } - - if (!allow_color_change) { - SendResponse(false, mobile_apis::Result::REJECTED); - return; + LOG4CXX_DEBUG(logger_, "Allow Night Color Scheme Change"); + app->set_night_color_scheme(msg_params[strings::night_color_scheme]); } (*message_)[strings::msg_params][strings::app_id] = app->app_id(); -- cgit v1.2.1 From de1ec4dff650680a3dad09b692fafaa297ab9889 Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Sun, 13 May 2018 23:47:04 +0300 Subject: Provide new image type Image.isTemplate --- src/components/application_manager/src/smart_object_keys.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index c3aba90dd5..1004e6cf7c 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -153,6 +153,7 @@ 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"; -- cgit v1.2.1 From 028ca237522c1c1693ca54049cf462a5122598e4 Mon Sep 17 00:00:00 2001 From: jacobkeeler Date: Mon, 14 May 2018 13:55:32 -0400 Subject: Prevent `INVALID_ID`responses from terminating valid requests --- .../application_manager/src/request_controller.cc | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/request_controller.cc b/src/components/application_manager/src/request_controller.cc index a6d78f24de..f341967842 100644 --- a/src/components/application_manager/src/request_controller.cc +++ b/src/components/application_manager/src/request_controller.cc @@ -50,6 +50,7 @@ RequestController::RequestController(const RequestControlerSettings& settings) : pool_state_(UNDEFINED) , pool_size_(settings.thread_pool_size()) , request_tracker_(settings) + , duplicate_message_count_() , timer_("AM RequestCtrlTimer", new timer::TimerTaskImpl( this, &RequestController::TimeoutThread)) @@ -230,6 +231,21 @@ void RequestController::TerminateRequest(const uint32_t correlation_id, << correlation_id << " connection_key = " << connection_key << " function_id = " << function_id << " force_terminate = " << force_terminate); + { + AutoLock auto_lock(duplicate_message_count_lock_); + auto dup_it = duplicate_message_count_.find(correlation_id); + if (duplicate_message_count_.end() != dup_it) { + duplicate_message_count_[correlation_id]--; + if (0 == duplicate_message_count_[correlation_id]) { + duplicate_message_count_.erase(dup_it); + } + LOG4CXX_DEBUG(logger_, + "Ignoring termination request due to duplicate correlation " + "ID being sent"); + return; + } + } + RequestInfoPtr request = waiting_for_response_.Find(connection_key, correlation_id); if (!request) { @@ -478,6 +494,15 @@ void RequestController::Worker::threadMain() { commands::CommandRequestImpl* cmd_request = dynamic_cast(request_ptr.get()); if (cmd_request != NULL) { + uint32_t corr_id = cmd_request->correlation_id(); + request_controller_->duplicate_message_count_lock_.Acquire(); + auto dup_it = + request_controller_->duplicate_message_count_.find(corr_id); + if (request_controller_->duplicate_message_count_.end() == dup_it) { + request_controller_->duplicate_message_count_[corr_id] = 0; + } + request_controller_->duplicate_message_count_[corr_id]++; + request_controller_->duplicate_message_count_lock_.Release(); cmd_request->SendResponse( false, mobile_apis::Result::INVALID_ID, "Duplicate correlation_id"); } -- cgit v1.2.1 From cc681f444642b7ff7cd9a6ff9ed7dfd192fd0f5c Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Mon, 29 Jan 2018 15:22:19 +0200 Subject: Fix A/V streaming starting for PROJECTION apps --- src/components/application_manager/src/application_manager_impl.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 248b54fee5..630815bf1b 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -4060,6 +4060,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) { -- cgit v1.2.1 From 9e76a1f8eb86f3851b6cff6379f2ed8531a0e4d6 Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Tue, 30 Jan 2018 17:05:27 +0200 Subject: Treat projection app as audio app Add projection app to audio app list as it can stream audio This is done to enable HMI leve switching to LIMITED level. --- src/components/application_manager/src/application_impl.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index ac21219d7d..3d3a541508 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -230,7 +230,8 @@ void ApplicationImpl::set_voice_communication_supported( } bool ApplicationImpl::IsAudioApplication() const { - return is_media_ || is_voice_communication_application_ || is_navi_; + return is_media_ || is_voice_communication_application_ || is_navi_ || + mobile_projection_enabled_; } void ApplicationImpl::SetRegularState(HmiStatePtr state) { -- cgit v1.2.1 From 6b43ffcdc661eb97a973c3a028af10076dd5e927 Mon Sep 17 00:00:00 2001 From: Ira Lytvynenko Date: Fri, 16 Mar 2018 11:18:26 +0200 Subject: Initial implementation --- .../application_manager/src/application_impl.cc | 4 + .../src/application_manager_impl.cc | 11 ++- .../hmi/on_exit_application_notification.cc | 6 +- .../application_manager/src/hmi_state.cc | 14 ++++ .../src/policies/policy_handler.cc | 11 ++- .../application_manager/src/smart_object_keys.cc | 1 + .../src/state_controller_impl.cc | 92 +++++++++++++++++----- 7 files changed, 114 insertions(+), 25 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index 3d3a541508..ace7d55860 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -234,6 +234,10 @@ bool ApplicationImpl::IsAudioApplication() const { mobile_projection_enabled_; } +bool ApplicationImpl::IsVideoApplication() const { + return is_navi_ || mobile_projection_enabled_; +} + void ApplicationImpl::SetRegularState(HmiStatePtr state) { LOG4CXX_AUTO_TRACE(logger_); state_.AddState(state); diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 630815bf1b..4bf45e2637 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), mobile_apis::HMILevel::INVALID_ENUM, mobile_apis::AudioStreamingState::INVALID_ENUM, + mobile_apis::VideoStreamingState::INVALID_ENUM, mobile_api::SystemContext::SYSCTXT_MAIN); application->SetInitialState(initial_state); @@ -661,9 +662,12 @@ bool ApplicationManagerImpl::ActivateApplication(ApplicationSharedPtr app) { resume_controller().OnAppActivated(app); HMILevel::eType hmi_level = HMILevel::HMI_FULL; AudioStreamingState::eType audio_state; + VideoStreamingState::eType video_state; app->IsAudioApplication() ? audio_state = AudioStreamingState::AUDIBLE : audio_state = AudioStreamingState::NOT_AUDIBLE; - state_ctrl_.SetRegularState(app, hmi_level, audio_state, false); + app->IsVideoApplication() ? video_state = VideoStreamingState::STREAMABLE + : video_state = VideoStreamingState::NOT_STREAMABLE; + state_ctrl_.SetRegularState(app, hmi_level, audio_state, video_state, false); return true; } @@ -840,10 +844,12 @@ HmiStatePtr ApplicationManagerImpl::CreateRegularState( utils::SharedPtr 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; } @@ -3738,6 +3744,9 @@ void ApplicationManagerImpl::SendHMIStatusNotification( message[strings::msg_params][strings::audio_streaming_state] = static_cast(app->audio_streaming_state()); + message[strings::msg_params][strings::video_streaming_state] = + static_cast(app->video_streaming_state()); + message[strings::msg_params][strings::system_context] = static_cast(app->system_context()); 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/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index bc1ccd8f42..17cbdb429d 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -45,6 +45,7 @@ HmiState::HmiState(utils::SharedPtr app, , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) + , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {} HmiState::HmiState(utils::SharedPtr app, @@ -54,6 +55,7 @@ HmiState::HmiState(utils::SharedPtr app, , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) + , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {} DEPRECATED HmiState::HmiState(uint32_t app_id, @@ -159,6 +161,18 @@ NaviStreamingHmiState::audio_streaming_state() const { return expected_state; } +mobile_apis::VideoStreamingState::eType +NaviStreamingHmiState::video_streaming_state() const { + using namespace helpers; + using namespace mobile_apis; + + VideoStreamingState::eType expected_state = parent()->video_streaming_state(); + if (!is_navi_app() && VideoStreamingState::STREAMABLE == expected_state) { + expected_state = VideoStreamingState::NOT_STREAMABLE; + } + return expected_state; +} + PhoneCallHmiState::PhoneCallHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_PHONE_CALL) {} diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 559b9c0035..77281f5a72 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -162,10 +162,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 +976,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; diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index c3aba90dd5..f56fd23c84 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"; diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 84081a3830..073c36aa51 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -41,10 +41,15 @@ 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()) { + bool level_changed = old_state->hmi_level() != new_state->hmi_level(); + bool audio_streaming_state_changed = + old_state->audio_streaming_state() != new_state->audio_streaming_state(); + bool video_streaming_state_changed = + old_state->video_streaming_state() != new_state->video_streaming_state(); + bool system_context_changed = + old_state->system_context() != new_state->system_context(); + if (level_changed || audio_streaming_state_changed || + video_streaming_state_changed || system_context_changed) { return true; } return false; @@ -76,6 +81,8 @@ void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, 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"); return; @@ -113,6 +120,7 @@ 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_); @@ -127,6 +135,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); } @@ -149,6 +158,7 @@ void StateControllerImpl::SetRegularState( 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,6 +167,7 @@ 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"); @@ -170,6 +181,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(system_context); SetRegularState(app, hmi_state, send_activate_app); } @@ -188,6 +200,7 @@ void StateControllerImpl::SetRegularState( 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); @@ -211,13 +224,16 @@ 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) { + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state) { CREATE_LOGGERPTR_LOCAL(logger_, "StateControllerImpl"); LOG4CXX_AUTO_TRACE(logger_); if (!app) { @@ -231,6 +247,7 @@ 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); } @@ -301,11 +318,17 @@ void StateControllerImpl::HmiLevelConflictResolver::operator()( "Application " << to_resolve->app_id() << " will change HMI level to " << result_hmi_level); - state_ctrl_->SetupRegularHmiState(to_resolve, - result_hmi_level, - result_hmi_level == HMILevel::HMI_LIMITED - ? AudioStreamingState::AUDIBLE - : AudioStreamingState::NOT_AUDIBLE); + VideoStreamingState::eType video_state = + result_hmi_level == HMILevel::HMI_LIMITED + ? VideoStreamingState::STREAMABLE + : VideoStreamingState::NOT_STREAMABLE; + AudioStreamingState::eType audio_state = + result_hmi_level == HMILevel::HMI_LIMITED + ? AudioStreamingState::AUDIBLE + : AudioStreamingState::NOT_AUDIBLE; + + state_ctrl_->SetupRegularHmiState( + to_resolve, result_hmi_level, audio_state, video_state); } else { LOG4CXX_DEBUG(logger_, "Application " << to_resolve->app_id() @@ -321,6 +344,7 @@ HmiStatePtr StateControllerImpl::ResolveHmiState(ApplicationSharedPtr app, LOG4CXX_DEBUG(logger_, "State to resolve: hmi_level " << state->hmi_level() << ", audio_state " + << state->video_streaming_state() << ", video_state " << state->audio_streaming_state() << ", system_context " << state->system_context()); @@ -329,6 +353,7 @@ HmiStatePtr StateControllerImpl::ResolveHmiState(ApplicationSharedPtr app, 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 +362,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(); @@ -506,6 +533,7 @@ void StateControllerImpl::SetupRegularHmiState(ApplicationSharedPtr app, 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,7 +552,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) { + const mobile_apis::AudioStreamingState::eType audio_state, + const mobile_apis::VideoStreamingState::eType video_state) { namespace HMILevel = mobile_apis::HMILevel; namespace AudioStreamingState = mobile_apis::AudioStreamingState; using helpers::Compare; @@ -537,6 +566,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); } @@ -675,15 +705,17 @@ void StateControllerImpl::OnStateChanged(ApplicationSharedPtr 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()); + "old: hmi_level " + << old_state->hmi_level() << ", audio_state " + << old_state->audio_streaming_state() << ", video_state " + << old_state->video_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()); + "new: hmi_level " + << new_state->hmi_level() << ", audio_state " + << new_state->audio_streaming_state() << ", video_state " + << old_state->video_streaming_state() << ", system_context " + << new_state->system_context()); if (IsStatusChanged(old_state, new_state)) { app_mngr_.SendHMIStatusNotification(app); if (new_state->hmi_level() == mobile_apis::HMILevel::HMI_NONE) { @@ -730,6 +762,7 @@ void StateControllerImpl::OnApplicationRegistered( 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(); @@ -812,9 +845,11 @@ void StateControllerImpl::DeactivateApp(ApplicationSharedPtr app) { if (app->IsAudioApplication()) { new_regular->set_hmi_level(HMILevel::HMI_LIMITED); new_regular->set_audio_streaming_state(AudioStreamingState::AUDIBLE); + new_regular->set_video_streaming_state(VideoStreamingState::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); @@ -968,4 +1003,23 @@ mobile_apis::AudioStreamingState::eType StateControllerImpl::CalcAudioState( return audio_state; } +mobile_apis::VideoStreamingState::eType StateControllerImpl::CalcVideoState( + ApplicationSharedPtr app, + const mobile_apis::HMILevel::eType hmi_level) const { + namespace HMILevel = mobile_apis::HMILevel; + namespace VideoStreamingState = mobile_apis::VideoStreamingState; + using helpers::Compare; + using helpers::EQ; + using helpers::ONE; + + VideoStreamingState::eType video_state = VideoStreamingState::NOT_STREAMABLE; + if (Compare( + hmi_level, HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { + if (app->IsVideoApplication()) { + video_state = VideoStreamingState::STREAMABLE; + } + } + return video_state; +} + } // namespace application_manager -- cgit v1.2.1 From b9f4fc26364c2c5de9df5754b711fcd2392c69b6 Mon Sep 17 00:00:00 2001 From: Ira Lytvynenko Date: Mon, 19 Mar 2018 13:24:56 +0200 Subject: Remove unused code --- src/components/application_manager/src/application_manager_impl.cc | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 4bf45e2637..822807a5ae 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -866,12 +866,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, -- cgit v1.2.1 From 859f1401b9915a29ed1973bd2efe2c1ee35ef9df Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Sun, 13 May 2018 19:13:30 +0300 Subject: Guarantee mutex release in StateControllerImpl::OnApplicationRegistered method --- .../src/state_controller_impl.cc | 39 ++++++++++++---------- 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 073c36aa51..321de77d8d 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -745,17 +745,18 @@ 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); @@ -811,16 +812,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) { -- cgit v1.2.1 From 594be81b947e6554171b43df6e3e5075a39f5bc2 Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Sun, 13 May 2018 22:14:41 +0300 Subject: Fix HMI state resolver according to requirments of 'Mobile Projection Phase 2' --- .../application_manager/src/application_impl.cc | 20 +- .../application_manager/src/hmi_state.cc | 95 +++-- .../src/state_controller_impl.cc | 403 ++++++++++++--------- 3 files changed, 314 insertions(+), 204 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc index ace7d55860..8fb88ad5ff 100644 --- a/src/components/application_manager/src/application_impl.cc +++ b/src/components/application_manager/src/application_impl.cc @@ -230,12 +230,26 @@ void ApplicationImpl::set_voice_communication_supported( } bool ApplicationImpl::IsAudioApplication() const { - return is_media_ || is_voice_communication_application_ || is_navi_ || - mobile_projection_enabled_; + 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 { - return is_navi_ || mobile_projection_enabled_; + 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/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 17cbdb429d..14cee28f91 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -32,6 +32,9 @@ */ #include "application_manager/hmi_state.h" +#include +#include +#include #include "application_manager/application_manager.h" #include "utils/helpers.h" @@ -65,6 +68,7 @@ DEPRECATED HmiState::HmiState(uint32_t app_id, , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) + , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { app_ = app_mngr_.application(app_id); } @@ -75,6 +79,7 @@ DEPRECATED HmiState::HmiState(uint32_t app_id, , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) + , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { app_ = app_mngr_.application(app_id); } @@ -134,43 +139,46 @@ mobile_apis::AudioStreamingState::eType TTSHmiState::audio_streaming_state() hmi_level(), HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { expected_state = AudioStreamingState::ATTENUATED; } + return expected_state; } -NaviStreamingHmiState::NaviStreamingHmiState(utils::SharedPtr app, - const ApplicationManager& app_mngr) - : HmiState(app, app_mngr, STATE_ID_NAVI_STREAMING) {} +VideoStreamingHmiState::VideoStreamingHmiState( + utils::SharedPtr app, const ApplicationManager& app_mngr) + : HmiState(app, app_mngr, STATE_ID_VIDEO_STREAMING) {} -DEPRECATED NaviStreamingHmiState::NaviStreamingHmiState( +DEPRECATED VideoStreamingHmiState::VideoStreamingHmiState( uint32_t app_id, const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_NAVI_STREAMING) {} + : HmiState(app_id, app_mngr, STATE_ID_VIDEO_STREAMING) {} mobile_apis::AudioStreamingState::eType -NaviStreamingHmiState::audio_streaming_state() const { +VideoStreamingHmiState::audio_streaming_state() const { using namespace helpers; using namespace mobile_apis; AudioStreamingState::eType expected_state = parent()->audio_streaming_state(); - if (!is_navi_app() && AudioStreamingState::AUDIBLE == expected_state) { + if (!app_->IsVideoApplication() && + Compare( + 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; } mobile_apis::VideoStreamingState::eType -NaviStreamingHmiState::video_streaming_state() const { - using namespace helpers; - using namespace mobile_apis; - - VideoStreamingState::eType expected_state = parent()->video_streaming_state(); - if (!is_navi_app() && VideoStreamingState::STREAMABLE == expected_state) { - expected_state = VideoStreamingState::NOT_STREAMABLE; +VideoStreamingHmiState::video_streaming_state() const { + if (app_->IsVideoApplication()) { + return parent()->video_streaming_state(); } - return expected_state; + + return mobile_apis::VideoStreamingState::NOT_STREAMABLE; } PhoneCallHmiState::PhoneCallHmiState(utils::SharedPtr app, @@ -222,6 +230,7 @@ mobile_apis::HMILevel::eType DeactivateHMI::hmi_level() const { HMILevel::HMI_NONE)) { return parent()->hmi_level(); } + return HMILevel::HMI_BACKGROUND; } @@ -234,20 +243,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(parent()->hmi_level(), - HMILevel::HMI_BACKGROUND, - HMILevel::HMI_NONE)) { - return parent()->hmi_level(); - } - if (is_navi_app() || is_voice_communication_app()) { - return HMILevel::HMI_LIMITED; + if (mobile_apis::HMILevel::HMI_NONE == parent()->hmi_level()) { + return mobile_apis::HMILevel::HMI_NONE; } - return HMILevel::HMI_BACKGROUND; + + return mobile_apis::HMILevel::HMI_BACKGROUND; } EmbeddedNavi::EmbeddedNavi(utils::SharedPtr app, @@ -271,4 +273,43 @@ mobile_apis::HMILevel::eType EmbeddedNavi::hmi_level() const { } return HMILevel::HMI_BACKGROUND; } + +namespace { +typedef boost::bimap StateID2StrMap; +const StateID2StrMap kStateID2StrMap = + boost::assign::list_of( + 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_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(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/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 321de77d8d..9ca8680d09 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 #include "application_manager/usage_statistics.h" #include "utils/helpers.h" #include "utils/make_shared.h" @@ -40,20 +41,18 @@ namespace application_manager { CREATE_LOGGERPTR_GLOBAL(logger_, "StateControllerImpl") -bool IsStatusChanged(HmiStatePtr old_state, HmiStatePtr new_state) { - bool level_changed = old_state->hmi_level() != new_state->hmi_level(); - bool audio_streaming_state_changed = - old_state->audio_streaming_state() != new_state->audio_streaming_state(); - bool video_streaming_state_changed = - old_state->video_streaming_state() != new_state->video_streaming_state(); - bool system_context_changed = - old_state->system_context() != new_state->system_context(); - if (level_changed || audio_streaming_state_changed || - video_streaming_state_changed || system_context_changed) { - 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) { @@ -107,7 +106,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"); @@ -268,85 +267,177 @@ 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( + 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( - 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( - 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(); + + if (mobile_apis::HMILevel::HMI_FULL == applied_hmi_level) { + using namespace helpers; + if (mobile_apis::VideoStreamingState::STREAMABLE == result_video_state || + Compare( + 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; + } + } else if (mobile_apis::HMILevel::HMI_LIMITED == applied_hmi_level) { + if (to_resolve_hmi_level == applied_hmi_level) { + 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); - VideoStreamingState::eType video_state = - result_hmi_level == HMILevel::HMI_LIMITED - ? VideoStreamingState::STREAMABLE - : VideoStreamingState::NOT_STREAMABLE; - AudioStreamingState::eType audio_state = - result_hmi_level == HMILevel::HMI_LIMITED - ? AudioStreamingState::AUDIBLE - : AudioStreamingState::NOT_AUDIBLE; - - state_ctrl_->SetupRegularHmiState( - to_resolve, result_hmi_level, audio_state, video_state); + "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_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->video_streaming_state() << ", video_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); @@ -372,11 +463,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( - 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; } @@ -402,20 +490,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( - 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); } @@ -451,13 +536,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); @@ -481,11 +561,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( - 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"); @@ -519,14 +596,10 @@ 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); @@ -577,28 +650,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(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) { @@ -704,19 +761,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() << ", video_state " - << old_state->video_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() << ", video_state " - << old_state->video_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(); @@ -841,14 +888,30 @@ 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(*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); - new_regular->set_video_streaming_state(VideoStreamingState::STREAMABLE); + + 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); @@ -869,7 +932,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); } @@ -914,11 +977,11 @@ void StateControllerImpl::OnAppDeactivated( } void StateControllerImpl::OnNaviStreamingStarted() { - ApplyTempState(); + ApplyTempState(); } void StateControllerImpl::OnNaviStreamingStopped() { - CancelTempState(); + CancelTempState(); } bool StateControllerImpl::IsStateActive(HmiState::StateID state_id) const { @@ -955,8 +1018,8 @@ HmiStatePtr StateControllerImpl::CreateHmiState( new_state = MakeShared(app, app_mngr_); break; } - case HmiState::STATE_ID_NAVI_STREAMING: { - new_state = MakeShared(app, app_mngr_); + case HmiState::STATE_ID_VIDEO_STREAMING: { + new_state = MakeShared(app, app_mngr_); break; } case HmiState::STATE_ID_REGULAR: { @@ -990,39 +1053,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( - 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 { - namespace HMILevel = mobile_apis::HMILevel; - namespace VideoStreamingState = mobile_apis::VideoStreamingState; - using helpers::Compare; - using helpers::EQ; - using helpers::ONE; - - VideoStreamingState::eType video_state = VideoStreamingState::NOT_STREAMABLE; - if (Compare( - hmi_level, HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { - if (app->IsVideoApplication()) { - video_state = VideoStreamingState::STREAMABLE; - } + auto state = mobile_apis::VideoStreamingState::NOT_STREAMABLE; + if (IsStreamableHMILevel(hmi_level) && app->IsVideoApplication()) { + state = mobile_apis::VideoStreamingState::STREAMABLE; } - return video_state; + + LOG4CXX_DEBUG(logger_, + "Calculated video state of app " + << app->app_id() << " for " << hmi_level << " HMI level is " + << state); + return state; } } // namespace application_manager -- cgit v1.2.1 From 1ce9e8a37b5d33f4d92bd658e42fdb9b8fa1cbae Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Sun, 13 May 2018 23:11:32 +0300 Subject: Minor changes: extend logs, fix methods descriptions --- .../src/application_manager_impl.cc | 28 ++++---- .../application_manager/src/application_state.cc | 1 - .../application_manager/src/hmi_state.cc | 12 +++- .../src/state_controller_impl.cc | 76 ++++++---------------- 4 files changed, 45 insertions(+), 72 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 822807a5ae..3dc529a26e 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -658,15 +658,17 @@ 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; - VideoStreamingState::eType video_state; - app->IsAudioApplication() ? audio_state = AudioStreamingState::AUDIBLE - : audio_state = AudioStreamingState::NOT_AUDIBLE; - app->IsVideoApplication() ? video_state = VideoStreamingState::STREAMABLE - : video_state = VideoStreamingState::NOT_STREAMABLE; + 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; } @@ -679,10 +681,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) { @@ -4528,7 +4530,6 @@ std::vector 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); @@ -4536,14 +4537,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/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 14cee28f91..8e93f278f0 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -40,6 +40,8 @@ namespace application_manager { +CREATE_LOGGERPTR_GLOBAL(logger_, "HmiState") + HmiState::HmiState(utils::SharedPtr app, const ApplicationManager& app_mngr, StateID state_id) @@ -49,7 +51,9 @@ HmiState::HmiState(utils::SharedPtr app, , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) - , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {} + , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { + LOG4CXX_DEBUG(logger_, *this); +} HmiState::HmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) @@ -59,7 +63,9 @@ HmiState::HmiState(utils::SharedPtr app, , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) - , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {} + , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { + LOG4CXX_DEBUG(logger_, *this); +} DEPRECATED HmiState::HmiState(uint32_t app_id, const ApplicationManager& app_mngr, @@ -71,6 +77,7 @@ DEPRECATED HmiState::HmiState(uint32_t app_id, , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { app_ = app_mngr_.application(app_id); + LOG4CXX_DEBUG(logger_, *this); } DEPRECATED HmiState::HmiState(uint32_t app_id, @@ -82,6 +89,7 @@ DEPRECATED HmiState::HmiState(uint32_t app_id, , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { app_ = app_mngr_.application(app_id); + LOG4CXX_DEBUG(logger_, *this); } void HmiState::set_parent(HmiStatePtr parent) { diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 9ca8680d09..942f9f0e3f 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -68,14 +68,12 @@ 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() == @@ -83,7 +81,7 @@ void StateControllerImpl::SetRegularState(ApplicationSharedPtr app, 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; } @@ -97,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( resolved_state->hmi_level()); @@ -121,12 +120,8 @@ void StateControllerImpl::SetRegularState( 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 = @@ -144,13 +139,8 @@ 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); @@ -169,12 +159,8 @@ void StateControllerImpl::SetRegularState( 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); @@ -187,12 +173,8 @@ void StateControllerImpl::SetRegularState( 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); @@ -209,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 = @@ -233,12 +211,8 @@ void StateControllerImpl::SetRegularState( ApplicationSharedPtr app, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state) { - 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(); DCHECK_OR_RETURN_VOID(prev_state); HmiStatePtr hmi_state = @@ -253,12 +227,8 @@ void StateControllerImpl::SetRegularState( 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); @@ -627,9 +597,6 @@ void StateControllerImpl::SetupRegularHmiState( const mobile_apis::HMILevel::eType hmi_level, const mobile_apis::AudioStreamingState::eType audio_state, const mobile_apis::VideoStreamingState::eType video_state) { - namespace HMILevel = mobile_apis::HMILevel; - namespace AudioStreamingState = mobile_apis::AudioStreamingState; - using helpers::Compare; LOG4CXX_AUTO_TRACE(logger_); DCHECK_OR_RETURN_VOID(app); HmiStatePtr prev_state = app->RegularHmiState(); @@ -702,7 +669,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(id); if (is_active) { if (Common_EventTypes::AUDIO_SOURCE == state_id) { @@ -747,6 +714,9 @@ void StateControllerImpl::on_event(const event_engine::Event& event) { break; } } + + LOG4CXX_WARN(logger_, + "Couldn't recognize state id (val='" << state_id << "')"); break; } default: @@ -772,15 +742,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( @@ -955,9 +923,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(); -- cgit v1.2.1 From aa68e6b05d540c176ed9cd01f3914d6d98dcc5e0 Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Fri, 18 May 2018 17:23:04 +0300 Subject: Change behavior for EmbeddedNavi event --- src/components/application_manager/src/hmi_state.cc | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 8e93f278f0..826b8ec6b7 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -276,9 +276,6 @@ 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; } -- cgit v1.2.1 From 3c143c901e9c73858437db29c0a9bbad26428b66 Mon Sep 17 00:00:00 2001 From: Andriy Byzhynar Date: Fri, 6 Apr 2018 19:33:55 +0300 Subject: Initial implementation Implemented function in PutFile which correctly calculates CRC32 checksum for std::vector Added comparison of calculated CRC checksum with received in PutFile request. Added PutFile response generation in case of CRC sum mismatch Fixed handling of unsigned integer values --- .../src/commands/mobile/put_file_request.cc | 46 +++++++++++++++++++--- .../application_manager/src/smart_object_keys.cc | 1 + 2 files changed, 41 insertions(+), 6 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/commands/mobile/put_file_request.cc b/src/components/application_manager/src/commands/mobile/put_file_request.cc index 602b420ba0..269c9c814e 100644 --- a/src/components/application_manager/src/commands/mobile/put_file_request.cc +++ b/src/components/application_manager/src/commands/mobile/put_file_request.cc @@ -38,6 +38,22 @@ #include "application_manager/application_impl.h" #include "utils/file_system.h" +#include + +namespace { +/** +* Calculates CRC32 checksum +* @param binary_data - input data for which CRC32 should be calculated +* @return calculated CRC32 checksum +*/ +uint32_t GetCrc32CheckSum(const std::vector& binary_data) { + const std::size_t file_size = binary_data.size(); + boost::crc_32_type result; + result.process_bytes(&binary_data[0], file_size); + return result.checksum(); +} + +} // namespace namespace application_manager { @@ -137,7 +153,7 @@ void PutFileRequest::Run() { is_persistent_file_ = false; bool is_system_file = false; length_ = binary_data.size(); - bool is_download_compleate = true; + bool is_download_complete = true; bool offset_exist = (*message_)[strings::msg_params].keyExists(strings::offset); @@ -187,11 +203,29 @@ void PutFileRequest::Run() { return; } const std::string full_path = file_path + "/" + sync_file_name_; - UNUSED(full_path); + const size_t bin_data_size = binary_data.size(); + + if ((*message_)[strings::msg_params].keyExists(strings::crc32_check_sum)) { + LOG4CXX_TRACE(logger_, "Binary Data Size: " << bin_data_size); + const uint32_t crc_received = + (*message_)[strings::msg_params][strings::crc32_check_sum].asUInt(); + LOG4CXX_TRACE(logger_, "CRC32 SUM Received: " << crc_received); + const uint32_t crc_calculated = GetCrc32CheckSum(binary_data); + LOG4CXX_TRACE(logger_, "CRC32 SUM Calculated: " << crc_calculated); + if (crc_calculated != crc_received) { + SendResponse(false, + mobile_apis::Result::CORRUPTED_DATA, + "CRC Check on file failed. File upload has been cancelled, " + "please retry.", + &response_params); + return; + } + } + LOG4CXX_DEBUG(logger_, - "Wrtiting " << binary_data.size() << "bytes to " << full_path - << " (current size is" - << file_system::FileSize(full_path) << ")"); + "Writing " << bin_data_size << " bytes to " << full_path + << " (current size is" + << file_system::FileSize(full_path) << ")"); mobile_apis::Result::eType save_result = application_manager_.SaveBinary( binary_data, file_path, sync_file_name_, offset_); @@ -211,7 +245,7 @@ void PutFileRequest::Run() { if (!is_system_file) { AppFile file(sync_file_name_, is_persistent_file_, - is_download_compleate, + is_download_complete, file_type_); if (0 == offset_) { diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index c3aba90dd5..75125ec90c 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -148,6 +148,7 @@ const char* sync_file_name = "syncFileName"; const char* file_name = "fileName"; const char* file_type = "fileType"; const char* file_size = "fileSize"; +const char* crc32_check_sum = "crc"; const char* request_type = "requestType"; const char* persistent_file = "persistentFile"; const char* file_data = "fileData"; -- cgit v1.2.1 From cf144fc1509f8baf77496d181b91791a2f5e3380 Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Mon, 21 May 2018 12:03:08 +0300 Subject: Review issues: remove deprecated VideoSourceHmiState constructor --- src/components/application_manager/src/hmi_state.cc | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 826b8ec6b7..ebc5a67143 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -155,10 +155,6 @@ VideoStreamingHmiState::VideoStreamingHmiState( utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_VIDEO_STREAMING) {} -DEPRECATED VideoStreamingHmiState::VideoStreamingHmiState( - uint32_t app_id, const ApplicationManager& app_mngr) - : HmiState(app_id, app_mngr, STATE_ID_VIDEO_STREAMING) {} - mobile_apis::AudioStreamingState::eType VideoStreamingHmiState::audio_streaming_state() const { using namespace helpers; -- cgit v1.2.1 From 7695be55f50f107c8162adfb794ba20e10e5e692 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 23 May 2018 11:21:34 -0400 Subject: DisplayName Implementation --- .../src/commands/mobile/register_app_interface_request.cc | 4 ++++ src/components/application_manager/src/smart_object_keys.cc | 1 + 2 files changed, 5 insertions(+) (limited to 'src/components/application_manager/src') 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..54def92111 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 @@ -453,6 +453,10 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, hmi_capabilities.display_capabilities()->getElement( hmi_response::display_type); + display_caps[hmi_response::display_name] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::display_name); + display_caps[hmi_response::text_fields] = hmi_capabilities.display_capabilities()->getElement( hmi_response::text_fields); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 26ca8e790f..47fae60728 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -437,6 +437,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"; -- cgit v1.2.1 From 767575366af311bbf33c26bd7ab74040f68890b7 Mon Sep 17 00:00:00 2001 From: "Andriy Byzhynar (GitHub)" Date: Thu, 19 Apr 2018 17:59:07 +0300 Subject: Initial implementation of Expandable Design for Proprietary Data Exchange Added new parameters to Mobile_API.xml & HMI_API.xml Added handling of new RequestType and RequestSubTypes to policy component Edited encoding & line endings in sdl_preloaded_pt.json Updated notifications triggering --- .../src/commands/command_request_impl.cc | 7 +- .../mobile/on_system_request_notification.cc | 35 +++++++-- .../mobile/register_app_interface_request.cc | 50 ++++++++---- .../src/commands/mobile/system_request.cc | 40 ++++++++-- .../src/message_helper/message_helper.cc | 13 +++- .../src/policies/policy_handler.cc | 89 +++++++++++++++++++--- .../application_manager/src/smart_object_keys.cc | 1 + 7 files changed, 195 insertions(+), 40 deletions(-) (limited to 'src/components/application_manager/src') 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/mobile/on_system_request_notification.cc b/src/components/application_manager/src/commands/mobile/on_system_request_notification.cc index c29ff3e2d3..78ab666056 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 @@ -65,19 +65,40 @@ void OnSystemRequestNotification::Run() { return; } - RequestType::eType request_type = static_cast( - (*message_)[strings::msg_params][strings::request_type].asInt()); + const mobile_apis::RequestType::eType request_type = + static_cast( + (*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( + 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 +118,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 +204,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/register_app_interface_request.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_request.cc index c799d68609..a58534b52b 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 @@ -822,8 +822,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,7 +834,7 @@ 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[hmi_response::policy_app_id] = policy_app_id; application[strings::icon] = application_impl.app_icon_path(); const smart_objects::SmartObject* ngn_media_screen_name = @@ -853,18 +854,41 @@ void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( application[strings::app_type] = *app_type; } - std::vector 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::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); 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..c081510e7c 100644 --- a/src/components/application_manager/src/commands/mobile/system_request.cc +++ b/src/components/application_manager/src/commands/mobile/system_request.cc @@ -454,17 +454,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( + 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 +507,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 +613,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/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index a848cf9ad9..d3af65effa 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(message)); diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 559b9c0035..b9446bcb3c 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); @@ -1024,7 +1026,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); @@ -1879,6 +1881,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 +1905,66 @@ bool PolicyHandler::IsRequestTypeAllowed( return false; } - std::vector 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::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 PolicyHandler::GetAppRequestTypes( @@ -1910,6 +1973,12 @@ const std::vector PolicyHandler::GetAppRequestTypes( return policy_manager_->GetAppRequestTypes(policy_app_id); } +const std::vector PolicyHandler::GetAppRequestSubTypes( + const std::string& policy_app_id) const { + POLICY_LIB_CHECK(std::vector()); + 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..7e21cb5d33 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -159,6 +159,7 @@ 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"; -- cgit v1.2.1 From 8838c28ed711008ae24be8a313e97c5dec677825 Mon Sep 17 00:00:00 2001 From: BSolonenko Date: Tue, 17 Apr 2018 16:23:53 +0300 Subject: Fix UT after implementation of Expandable Design --- .../src/commands/mobile/on_system_request_notification.cc | 1 + src/components/application_manager/src/commands/mobile/system_request.cc | 1 + 2 files changed, 2 insertions(+) (limited to 'src/components/application_manager/src') 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 78ab666056..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" 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 c081510e7c..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" -- cgit v1.2.1 From e76fd11ca12f6d36f408977ab3c506ba9568a7a8 Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Thu, 24 May 2018 14:45:28 +0300 Subject: Fix HMI conflict resolving for applied app in LIMITED state --- .../src/state_controller_impl.cc | 24 ++++++++-------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 942f9f0e3f..1eb75c4451 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -361,21 +361,15 @@ void StateControllerImpl::HmiLevelConflictResolver::operator()( mobile_apis::HMILevel::eType result_hmi_level = state_to_resolve->hmi_level(); - if (mobile_apis::HMILevel::HMI_FULL == applied_hmi_level) { - using namespace helpers; - if (mobile_apis::VideoStreamingState::STREAMABLE == result_video_state || - Compare( - 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; - } - } else if (mobile_apis::HMILevel::HMI_LIMITED == applied_hmi_level) { - if (to_resolve_hmi_level == applied_hmi_level) { - result_hmi_level = mobile_apis::HMILevel::HMI_BACKGROUND; - } + using namespace helpers; + if (mobile_apis::VideoStreamingState::STREAMABLE == result_video_state || + Compare( + 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, -- cgit v1.2.1 From 0e8d705df1317f8259bf41910aff78a525713ce0 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 25 May 2018 10:51:38 -0400 Subject: Check if displayName key exists --- .../src/commands/mobile/register_app_interface_request.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/components/application_manager/src') 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 54def92111..5783d52b20 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 @@ -453,9 +453,11 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, hmi_capabilities.display_capabilities()->getElement( hmi_response::display_type); - display_caps[hmi_response::display_name] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::display_name); + 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::text_fields] = hmi_capabilities.display_capabilities()->getElement( -- cgit v1.2.1 From 6e9ce7fedfd363a51fa3ac7fb31ccdf00defd201 Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Fri, 25 May 2018 14:03:29 +0300 Subject: Provide specific behavior for navigation streaming HMI state --- .../src/application_manager_impl.cc | 5 ++- .../application_manager/src/hmi_state.cc | 36 +++++++++++++--------- .../src/state_controller_impl.cc | 22 ++++++++++--- 3 files changed, 41 insertions(+), 22 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 3dc529a26e..408dcbf1da 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -3562,7 +3562,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); @@ -3575,11 +3574,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); } } diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index ebc5a67143..73d4b80a55 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -155,17 +155,31 @@ VideoStreamingHmiState::VideoStreamingHmiState( utils::SharedPtr 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 app, + const ApplicationManager& app_mngr) + : VideoStreamingHmiState(app, app_mngr) { + set_state_id(STATE_ID_NAVI_STREAMING); +} + mobile_apis::AudioStreamingState::eType -VideoStreamingHmiState::audio_streaming_state() const { +NaviStreamingHmiState::audio_streaming_state() const { using namespace helpers; using namespace mobile_apis; AudioStreamingState::eType expected_state = parent()->audio_streaming_state(); - if (!app_->IsVideoApplication() && - Compare( - expected_state, - AudioStreamingState::AUDIBLE, - AudioStreamingState::ATTENUATED)) { + if (!is_navi_app() && Compare( + expected_state, + AudioStreamingState::AUDIBLE, + AudioStreamingState::ATTENUATED)) { if (app_mngr_.is_attenuated_supported()) { expected_state = AudioStreamingState::ATTENUATED; } else { @@ -176,15 +190,6 @@ VideoStreamingHmiState::audio_streaming_state() const { return expected_state; } -mobile_apis::VideoStreamingState::eType -VideoStreamingHmiState::video_streaming_state() const { - if (app_->IsVideoApplication()) { - return parent()->video_streaming_state(); - } - - return mobile_apis::VideoStreamingState::NOT_STREAMABLE; -} - PhoneCallHmiState::PhoneCallHmiState(utils::SharedPtr app, const ApplicationManager& app_mngr) : HmiState(app, app_mngr, STATE_ID_PHONE_CALL) {} @@ -287,6 +292,7 @@ const StateID2StrMap kStateID2StrMap = 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"); diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc index 1eb75c4451..9615656675 100644 --- a/src/components/application_manager/src/state_controller_impl.cc +++ b/src/components/application_manager/src/state_controller_impl.cc @@ -936,12 +936,22 @@ void StateControllerImpl::OnAppDeactivated( DeactivateApp(app); } -void StateControllerImpl::OnNaviStreamingStarted() { - ApplyTempState(); +void StateControllerImpl::OnVideoStreamingStarted( + ApplicationConstSharedPtr app) { + if (app->is_navi()) { + ApplyTempState(); + } else { + ApplyTempState(); + } } -void StateControllerImpl::OnNaviStreamingStopped() { - CancelTempState(); +void StateControllerImpl::OnVideoStreamingStopped( + ApplicationConstSharedPtr app) { + if (app->is_navi()) { + CancelTempState(); + } else { + CancelTempState(); + } } bool StateControllerImpl::IsStateActive(HmiState::StateID state_id) const { @@ -982,6 +992,10 @@ HmiStatePtr StateControllerImpl::CreateHmiState( new_state = MakeShared(app, app_mngr_); break; } + case HmiState::STATE_ID_NAVI_STREAMING: { + new_state = MakeShared(app, app_mngr_); + break; + } case HmiState::STATE_ID_REGULAR: { new_state = MakeShared(app, app_mngr_); break; -- cgit v1.2.1 From 7fdf6ada7dbe538283538aed93a27c40e8f7d52c Mon Sep 17 00:00:00 2001 From: Alexander Kutsan Date: Fri, 6 Apr 2018 11:36:04 +0300 Subject: Add icon resumption parameter to strings Implementation of proposal 0041-appicon-resumption.md Technical task : https://github.com/smartdevicelink/sdl_core/issues/1456 Add response parameter IconResumed Set response parameter iconResumed to true in case if app icon exist otherwise set false Implementation of proposal 0041-appicon-resumption.md Technical task : https://github.com/smartdevicelink/sdl_core/issues/1456 --- .../src/commands/mobile/register_app_interface_request.cc | 5 +++++ src/components/application_manager/src/smart_object_keys.cc | 1 + 2 files changed, 6 insertions(+) (limited to 'src/components/application_manager/src') 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..994e8f4995 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; @@ -719,6 +720,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); diff --git a/src/components/application_manager/src/smart_object_keys.cc b/src/components/application_manager/src/smart_object_keys.cc index 421796c388..e4a31a2576 100644 --- a/src/components/application_manager/src/smart_object_keys.cc +++ b/src/components/application_manager/src/smart_object_keys.cc @@ -151,6 +151,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"; -- cgit v1.2.1 From 6829877a77d01eaaa8718e0960feea8ea7966895 Mon Sep 17 00:00:00 2001 From: Alexander Kutsan Date: Fri, 6 Apr 2018 11:36:54 +0300 Subject: Setting app icon to application in case if it exist on file system Implementation of proposal 0041-appicon-resumption.md Technical task : https://github.com/smartdevicelink/sdl_core/issues/1456 Setup Icon to application if icon exist on file system Implementation of proposal 0041-appicon-resumption.md Technical task : https://github.com/smartdevicelink/sdl_core/issues/1456 --- src/components/application_manager/src/application_manager_impl.cc | 7 +++++++ .../src/commands/mobile/register_app_interface_request.cc | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 248b54fee5..3ead8fe65e 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -623,6 +623,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 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 994e8f4995..d32afad00b 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 @@ -839,7 +839,9 @@ void RegisterAppInterfaceRequest::SendOnAppRegisteredNotificationToHMI( 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(); + 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(); -- cgit v1.2.1 From 59a89274424db93a19f1b1a777e50af7bce3a949 Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Fri, 6 Apr 2018 16:37:35 +0300 Subject: Save icon for resumtion after successful SetAppIcon --- .../src/commands/mobile/set_app_icon_request.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/components/application_manager/src') 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 #include "application_manager/commands/mobile/set_app_icon_request.h" +#include + #include "application_manager/message_helper.h" #include "application_manager/application_impl.h" #include "interfaces/MOBILE_API.h" @@ -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_, -- cgit v1.2.1 From bd5a426de8c197eab2f0f2277d48dfef51b2a989 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 25 May 2018 13:43:25 -0400 Subject: Add checks to display capabilities --- .../mobile/register_app_interface_request.cc | 100 ++++++++++++--------- 1 file changed, 56 insertions(+), 44 deletions(-) (limited to 'src/components/application_manager/src') 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..64d549b6d5 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 @@ -449,50 +449,62 @@ 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); - - display_caps[hmi_response::media_clock_formats] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::media_clock_formats); - - display_caps[hmi_response::templates_available] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::templates_available); - - display_caps[hmi_response::screen_params] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::screen_params); - - display_caps[hmi_response::num_custom_presets_available] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::num_custom_presets_available); - - display_caps[hmi_response::graphic_supported] = - (hmi_capabilities.display_capabilities() - ->getElement(hmi_response::image_capabilities) - .length() > 0); - - display_caps[hmi_response::templates_available] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::templates_available); - - display_caps[hmi_response::screen_params] = - hmi_capabilities.display_capabilities()->getElement( - hmi_response::screen_params); - - 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::display_type)) { + display_caps[hmi_response::display_type] = + hmi_capabilities.display_capabilities()->getElement( + hmi_response::display_type); + } + + 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); + } + + 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); + } + + 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); + } + + 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); + } + + 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); + } + + 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); + } + + 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()) { -- cgit v1.2.1 From 2f93ba5c58812ff714f63b0cb219b3dc3017b021 Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Fri, 25 May 2018 20:28:44 +0300 Subject: Additional fixes after ATF testing Fixed OnCertificateUpdated notification callback for empty certificate Fixed GetSystemTime triggering Fixed handshake resuming on system time arrived Fixed wrong logic in case system time is not ready Removed redundant logic for non-navi applications Removed PTU triggerring for navi on empty certificate in DB --- .../application_manager/src/application_manager_impl.cc | 3 ++- .../src/system_time/system_time_handler_impl.cc | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 5aa72d77e5..8d372f4fd2 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -1691,8 +1691,9 @@ bool ApplicationManagerImpl::OnHandshakeDone( return false; } -void ApplicationManagerImpl::OnHandshakeFailed() { +bool ApplicationManagerImpl::OnHandshakeFailed() { LOG4CXX_AUTO_TRACE(logger_); + return false; } void ApplicationManagerImpl::OnCertificateUpdateRequired() { diff --git a/src/components/application_manager/src/system_time/system_time_handler_impl.cc b/src/components/application_manager/src/system_time/system_time_handler_impl.cc index a91fb16197..6ae6d3e901 100644 --- a/src/components/application_manager/src/system_time/system_time_handler_impl.cc +++ b/src/components/application_manager/src/system_time/system_time_handler_impl.cc @@ -45,7 +45,7 @@ SystemTimeHandlerImpl::SystemTimeHandlerImpl( ApplicationManager& application_manager) : event_engine::EventObserver(application_manager.event_dispatcher()) , utc_time_can_be_received_(false) - , schedule_request_(false) + , awaiting_get_system_time_(false) , system_time_listener_(NULL) , app_manager_(application_manager) { LOG4CXX_AUTO_TRACE(logger_); @@ -67,7 +67,6 @@ void SystemTimeHandlerImpl::DoSystemTimeQuery() { LOG4CXX_INFO(logger_, "Navi module is not yet ready." << "Will process request once it became ready."); - schedule_request_ = true; return; } SendTimeRequest(); @@ -99,11 +98,18 @@ bool SystemTimeHandlerImpl::utc_time_can_be_received() const { void SystemTimeHandlerImpl::SendTimeRequest() { LOG4CXX_AUTO_TRACE(logger_); + + if (awaiting_get_system_time_) { + LOG4CXX_WARN(logger_, "Another GetSystemTime request in progress. Skipped"); + return; + } + using namespace application_manager; uint32_t correlation_id = app_manager_.GetNextHMICorrelationID(); subscribe_on_event(hmi_apis::FunctionID::BasicCommunication_GetSystemTime, correlation_id); MessageHelper::SendGetSystemTimeRequest(correlation_id, app_manager_); + awaiting_get_system_time_ = true; } void SystemTimeHandlerImpl::on_event( @@ -128,10 +134,6 @@ void SystemTimeHandlerImpl::ProcessSystemTimeReadyNotification() { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(state_lock_); utc_time_can_be_received_ = true; - if (schedule_request_) { - SendTimeRequest(); - schedule_request_ = false; - } unsubscribe_from_event( hmi_apis::FunctionID::BasicCommunication_OnSystemTimeReady); } @@ -164,6 +166,8 @@ void SystemTimeHandlerImpl::ProcessSystemTimeResponse( if (system_time_listener_) { system_time_listener_->OnSystemTimeArrived(last_time_); } + sync_primitives::AutoLock state_lock(state_lock_); + awaiting_get_system_time_ = false; } } // namespace application_manager -- cgit v1.2.1 From d073d384e0f1f65b26ea1be43bfc76752491fe4c Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 31 May 2018 10:27:59 -0400 Subject: Remove extra line and fix style --- .../src/commands/mobile/set_display_layout_request.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/components/application_manager/src') 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"); -- cgit v1.2.1 From e2dccaa5d115a4e5de899909c253a5add400c11a Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Thu, 24 May 2018 10:45:08 -0400 Subject: Added "FILE" SpeechCapabilities type and updated TTSChunk description. --- src/components/application_manager/src/hmi_capabilities_impl.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index 278e4761db..6758ab0e65 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)); -- cgit v1.2.1 From 47b7b86071d92b9074c504075cd25f563bc9d46b Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Fri, 1 Jun 2018 14:11:15 -0700 Subject: Validate existence of files used in TtsChunks --- .../src/commands/mobile/alert_maneuver_request.cc | 15 ++++++ .../src/commands/mobile/alert_request.cc | 17 +++++++ .../commands/mobile/change_registration_request.cc | 17 +++++++ .../mobile/perform_audio_pass_thru_request.cc | 20 +++++++- .../commands/mobile/perform_interaction_request.cc | 57 ++++++++++++++++++++-- .../mobile/register_app_interface_request.cc | 23 +++++++-- .../mobile/set_global_properties_request.cc | 49 +++++++++++++++++-- .../src/commands/mobile/speak_request.cc | 15 ++++++ .../src/message_helper/message_helper.cc | 42 ++++++++++++++-- 9 files changed, 236 insertions(+), 19 deletions(-) (limited to 'src/components/application_manager/src') 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/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 #include #include #include "application_manager/commands/mobile/perform_interaction_request.h" @@ -536,9 +537,21 @@ void PerformInteractionRequest::SendVRPerformInteractionRequest( } } + std::vector 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 d32afad00b..b5573c0680 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 @@ -179,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() {} @@ -320,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)) { @@ -694,9 +707,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 @@ -1023,7 +1036,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_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 +#include #include #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 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/message_helper/message_helper.cc b/src/components/application_manager/src/message_helper/message_helper.cc index a848cf9ad9..d10ede4637 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -2745,11 +2745,24 @@ mobile_apis::Result::eType MessageHelper::VerifyImageApplyPath( } const std::string& file_name = image[strings::value].asString(); + const utils::SharedPtr full_file_path = + CheckAppFileExists(file_name, app, app_mngr); + if (full_file_path) { + image[strings::value] = *full_file_path; + return mobile_apis::Result::SUCCESS; + } + return mobile_apis::Result::INVALID_DATA; +} +utils::SharedPtr MessageHelper::CheckAppFileExists( + 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 utils::SharedPtr(); } std::string full_file_path; @@ -2775,12 +2788,31 @@ 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 utils::SharedPtr(); } - return mobile_apis::Result::SUCCESS; + utils::SharedPtr path_ptr(new std::string(full_file_path)); + return path_ptr; +} + +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) { + utils::SharedPtr full_file_path = CheckAppFileExists( + tts_chunk[strings::text].asString(), app, app_mngr); + if (!full_file_path) { + result = mobile_apis::Result::FILE_NOT_FOUND; + } else { + tts_chunk[strings::text] = *full_file_path; + } + } + } + return result; } mobile_apis::Result::eType MessageHelper::VerifyImage( @@ -3024,4 +3056,4 @@ bool MessageHelper::PrintSmartObject(const smart_objects::SmartObject& object) { return true; } -} // namespace application_manager +} // namespace application_manager \ No newline at end of file -- cgit v1.2.1 From 112c685ae48d7cf939e3d2147453de1719862ec6 Mon Sep 17 00:00:00 2001 From: AKalinich-Luxoft Date: Mon, 4 Jun 2018 17:19:21 +0300 Subject: Move out unrelated to feature changes There was included some changes related to certificate processing. They will be included into related pull request --- .../application_manager/src/policies/policy_handler.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 98fb6bae65..bbf391a9f1 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1765,11 +1765,11 @@ void PolicyHandler::OnCertificateDecrypted(bool is_succeeded) { void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) { LOG4CXX_AUTO_TRACE(logger_); sync_primitives::AutoLock lock(listeners_lock_); - std::for_each( - listeners_.begin(), - listeners_.end(), - std::bind2nd(std::mem_fun(&PolicyHandlerObserver::OnCertificateUpdated), - certificate_data)); + HandlersCollection::const_iterator it = listeners_.begin(); + for (; it != listeners_.end(); ++it) { + PolicyHandlerObserver* observer = *it; + observer->OnCertificateUpdated(certificate_data); + } } #endif // EXTERNAL_PROPRIETARY_MODE -- cgit v1.2.1 From 3cec3966343d95fff2626ce11a46aedd42d0eea8 Mon Sep 17 00:00:00 2001 From: Elvis Kuliiev Date: Wed, 6 Jun 2018 19:39:23 +0300 Subject: Review issues: Remove changes from DEPRECATED HmiState methods --- src/components/application_manager/src/hmi_state.cc | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc index 73d4b80a55..e1bc2b5125 100644 --- a/src/components/application_manager/src/hmi_state.cc +++ b/src/components/application_manager/src/hmi_state.cc @@ -74,10 +74,8 @@ DEPRECATED HmiState::HmiState(uint32_t app_id, , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) - , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { app_ = app_mngr_.application(app_id); - LOG4CXX_DEBUG(logger_, *this); } DEPRECATED HmiState::HmiState(uint32_t app_id, @@ -86,10 +84,8 @@ DEPRECATED HmiState::HmiState(uint32_t app_id, , app_mngr_(app_mngr) , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM) , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM) - , video_streaming_state_(mobile_apis::VideoStreamingState::INVALID_ENUM) , system_context_(mobile_apis::SystemContext::INVALID_ENUM) { app_ = app_mngr_.application(app_id); - LOG4CXX_DEBUG(logger_, *this); } void HmiState::set_parent(HmiStatePtr parent) { @@ -147,7 +143,6 @@ mobile_apis::AudioStreamingState::eType TTSHmiState::audio_streaming_state() hmi_level(), HMILevel::HMI_FULL, HMILevel::HMI_LIMITED)) { expected_state = AudioStreamingState::ATTENUATED; } - return expected_state; } -- cgit v1.2.1 From 0391ec0254aa19869c4e72a1201e19d64d06e0ca Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 6 Jun 2018 15:52:36 -0400 Subject: Omit display capability from RAI response if mandatory display capabilities are missing --- .../src/commands/mobile/register_app_interface_request.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/components/application_manager/src') 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 64d549b6d5..5970fb4d06 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 @@ -449,11 +449,15 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, smart_objects::SmartObject& display_caps = response_params[hmi_response::display_capabilities]; + bool missing_mandatory_capabilities = false; + 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); + } else { + missing_mandatory_capabilities = true; } if (hmi_capabilities.display_capabilities()->keyExists( @@ -461,6 +465,8 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, display_caps[hmi_response::text_fields] = hmi_capabilities.display_capabilities()->getElement( hmi_response::text_fields); + } else { + missing_mandatory_capabilities = true; } if (hmi_capabilities.display_capabilities()->keyExists( @@ -475,6 +481,8 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, display_caps[hmi_response::media_clock_formats] = hmi_capabilities.display_capabilities()->getElement( hmi_response::media_clock_formats); + } else { + missing_mandatory_capabilities = true; } if (hmi_capabilities.display_capabilities()->keyExists( @@ -505,6 +513,11 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, ->getElement(hmi_response::image_capabilities) .length() > 0); } + + if (missing_mandatory_capabilities) { + // Mandatory Display Capability Parameters were missing, + response_params.erase(hmi_response::display_capabilities); + } } if (hmi_capabilities.audio_pass_thru_capabilities()) { -- cgit v1.2.1 From e1f257f0803056a02962626b94949d96e212cb1a Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 6 Jun 2018 16:16:04 -0400 Subject: Revert "Omit display capability from RAI response if mandatory display capabilities are missing" This reverts commit 0391ec0254aa19869c4e72a1201e19d64d06e0ca. --- .../src/commands/mobile/register_app_interface_request.cc | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'src/components/application_manager/src') 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 5970fb4d06..64d549b6d5 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 @@ -449,15 +449,11 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, smart_objects::SmartObject& display_caps = response_params[hmi_response::display_capabilities]; - bool missing_mandatory_capabilities = false; - 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); - } else { - missing_mandatory_capabilities = true; } if (hmi_capabilities.display_capabilities()->keyExists( @@ -465,8 +461,6 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, display_caps[hmi_response::text_fields] = hmi_capabilities.display_capabilities()->getElement( hmi_response::text_fields); - } else { - missing_mandatory_capabilities = true; } if (hmi_capabilities.display_capabilities()->keyExists( @@ -481,8 +475,6 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, display_caps[hmi_response::media_clock_formats] = hmi_capabilities.display_capabilities()->getElement( hmi_response::media_clock_formats); - } else { - missing_mandatory_capabilities = true; } if (hmi_capabilities.display_capabilities()->keyExists( @@ -513,11 +505,6 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params, ->getElement(hmi_response::image_capabilities) .length() > 0); } - - if (missing_mandatory_capabilities) { - // Mandatory Display Capability Parameters were missing, - response_params.erase(hmi_response::display_capabilities); - } } if (hmi_capabilities.audio_pass_thru_capabilities()) { -- cgit v1.2.1 From d38697a1f064f69cd591b3d9833215707efd54a0 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Wed, 6 Jun 2018 16:27:51 -0400 Subject: Check for mandatory parameters in display_capabilities() --- .../src/hmi_capabilities_impl.cc | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index 278e4761db..5babc40692 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -744,6 +744,30 @@ const smart_objects::SmartObject* HMICapabilitiesImpl::tts_supported_languages() const smart_objects::SmartObject* HMICapabilitiesImpl::display_capabilities() const { + if (!display_capabilities_->keyExists(hmi_response::display_type)) { + LOG4CXX_ERROR( + logger_, + "Core is missing mandatory displayCapability paramter: displayType"); + return NULL; + } + if (!display_capabilities_->keyExists(hmi_response::text_fields)) { + LOG4CXX_ERROR( + logger_, + "Core is missing mandatory displayCapability paramter: textFields"); + return NULL; + } + if (!display_capabilities_->keyExists(hmi_response::media_clock_formats)) { + LOG4CXX_ERROR(logger_, + "Core is missing mandatory displayCapability paramter: " + "mediaClockFormats"); + return NULL; + } + if (!display_capabilities_->keyExists(hmi_response::graphic_supported)) { + LOG4CXX_ERROR(logger_, + "Core is missing mandatory displayCapability paramter: " + "graphicSupported"); + return NULL; + } return display_capabilities_; } -- cgit v1.2.1 From 6800260da4fbb65f652b5128d8a0d19e71f5ff31 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Thu, 7 Jun 2018 16:30:54 -0400 Subject: Check if display capabilities struct is valid before setting value --- .../src/application_manager_impl.cc | 17 +++++++++++ .../src/hmi_capabilities_impl.cc | 35 +++++----------------- 2 files changed, 25 insertions(+), 27 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index 248b54fee5..fd0dd0ba3b 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -4456,6 +4456,23 @@ std::vector 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(); diff --git a/src/components/application_manager/src/hmi_capabilities_impl.cc b/src/components/application_manager/src/hmi_capabilities_impl.cc index 5babc40692..f64b80a088 100644 --- a/src/components/application_manager/src/hmi_capabilities_impl.cc +++ b/src/components/application_manager/src/hmi_capabilities_impl.cc @@ -551,10 +551,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( @@ -744,30 +749,6 @@ const smart_objects::SmartObject* HMICapabilitiesImpl::tts_supported_languages() const smart_objects::SmartObject* HMICapabilitiesImpl::display_capabilities() const { - if (!display_capabilities_->keyExists(hmi_response::display_type)) { - LOG4CXX_ERROR( - logger_, - "Core is missing mandatory displayCapability paramter: displayType"); - return NULL; - } - if (!display_capabilities_->keyExists(hmi_response::text_fields)) { - LOG4CXX_ERROR( - logger_, - "Core is missing mandatory displayCapability paramter: textFields"); - return NULL; - } - if (!display_capabilities_->keyExists(hmi_response::media_clock_formats)) { - LOG4CXX_ERROR(logger_, - "Core is missing mandatory displayCapability paramter: " - "mediaClockFormats"); - return NULL; - } - if (!display_capabilities_->keyExists(hmi_response::graphic_supported)) { - LOG4CXX_ERROR(logger_, - "Core is missing mandatory displayCapability paramter: " - "graphicSupported"); - return NULL; - } return display_capabilities_; } -- cgit v1.2.1 From 0a4344894d21e90116476c58d82a0c2995f9008b Mon Sep 17 00:00:00 2001 From: Jacob Keeler Date: Fri, 8 Jun 2018 11:25:06 -0400 Subject: Set full file path for files that aren't found --- .../src/message_helper/message_helper.cc | 33 +++++++++------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'src/components/application_manager/src') 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 46620e878a..b674a090c0 100644 --- a/src/components/application_manager/src/message_helper/message_helper.cc +++ b/src/components/application_manager/src/message_helper/message_helper.cc @@ -2756,24 +2756,23 @@ mobile_apis::Result::eType MessageHelper::VerifyImageApplyPath( } const std::string& file_name = image[strings::value].asString(); - const utils::SharedPtr full_file_path = - CheckAppFileExists(file_name, app, app_mngr); - if (full_file_path) { - image[strings::value] = *full_file_path; + 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; } -utils::SharedPtr MessageHelper::CheckAppFileExists( - std::string file_name, - ApplicationConstSharedPtr app, - ApplicationManager& app_mngr) { +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 utils::SharedPtr(); + return ""; } std::string full_file_path; @@ -2799,12 +2798,7 @@ utils::SharedPtr MessageHelper::CheckAppFileExists( full_file_path += file_name; } - if (!file_system::FileExists(full_file_path)) { - return utils::SharedPtr(); - } - - utils::SharedPtr path_ptr(new std::string(full_file_path)); - return path_ptr; + return full_file_path; } mobile_apis::Result::eType MessageHelper::VerifyTtsFiles( @@ -2814,12 +2808,11 @@ mobile_apis::Result::eType MessageHelper::VerifyTtsFiles( 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) { - utils::SharedPtr full_file_path = CheckAppFileExists( - tts_chunk[strings::text].asString(), app, app_mngr); - if (!full_file_path) { + 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; - } else { - tts_chunk[strings::text] = *full_file_path; } } } -- cgit v1.2.1 From efaf3a7abaa037e4168e137c15c2a0955bf32028 Mon Sep 17 00:00:00 2001 From: "Ira Lytvynenko (GitHub)" Date: Thu, 14 Jun 2018 13:39:17 +0300 Subject: Fix build with EXTERNAL PROPRIETARY policy flag --- src/components/application_manager/src/policies/policy_handler.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 123606a11e..4d1805d2a5 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1250,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::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( -- cgit v1.2.1 From 9af76249783a92cb0366dd4c8c569839d13f38e0 Mon Sep 17 00:00:00 2001 From: JackLivio Date: Fri, 15 Jun 2018 15:08:21 -0400 Subject: Style Fix --- .../application_manager/src/policies/policy_handler.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/components/application_manager/src') diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc index 4d1805d2a5..67658c2809 100644 --- a/src/components/application_manager/src/policies/policy_handler.cc +++ b/src/components/application_manager/src/policies/policy_handler.cc @@ -1250,12 +1250,12 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification( if (is_allowed) { // Send HMI status notification to mobile // Put application in full - AudioStreamingState::eType audio_state = app->IsAudioApplication() - ? AudioStreamingState::AUDIBLE - : AudioStreamingState::NOT_AUDIBLE; - VideoStreamingState::eType video_state = app->IsVideoApplication() - ? VideoStreamingState::STREAMABLE - : VideoStreamingState::NOT_STREAMABLE; + 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, audio_state, video_state, true); -- cgit v1.2.1