summaryrefslogtreecommitdiff
path: root/src/components/application_manager/src
diff options
context:
space:
mode:
authorJackLivio <jack@livio.io>2018-02-12 16:16:18 -0500
committerGitHub <noreply@github.com>2018-02-12 16:16:18 -0500
commit3e0852ef27d0fff950ea4a1dae136c972c40c759 (patch)
tree4d1aed127f42444c740a1c414c01177e70340b81 /src/components/application_manager/src
parent11ce1efd850cadbe63a9ac8017b49b372afc5c3f (diff)
parent37614e497366fb2a91f788da72fc9046527fcff2 (diff)
downloadsdl_core-3e0852ef27d0fff950ea4a1dae136c972c40c759.tar.gz
Merge branch 'release/4.5.0' into fix/OnDriverDistruction
Diffstat (limited to 'src/components/application_manager/src')
-rw-r--r--src/components/application_manager/src/application_impl.cc46
-rw-r--r--src/components/application_manager/src/application_manager_impl.cc463
-rw-r--r--src/components/application_manager/src/command_holder_impl.cc141
-rw-r--r--src/components/application_manager/src/commands/command_impl.cc67
-rw-r--r--src/components/application_manager/src/commands/command_request_impl.cc1
-rw-r--r--src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc44
-rw-r--r--src/components/application_manager/src/commands/hmi/notification_from_hmi.cc2
-rw-r--r--src/components/application_manager/src/commands/hmi/notification_to_hmi.cc8
-rw-r--r--src/components/application_manager/src/commands/hmi/on_app_unregistered_notification.cc6
-rw-r--r--src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc1
-rw-r--r--src/components/application_manager/src/commands/hmi/request_from_hmi.cc2
-rw-r--r--src/components/application_manager/src/commands/hmi/request_to_hmi.cc8
-rw-r--r--src/components/application_manager/src/commands/hmi/response_from_hmi.cc2
-rw-r--r--src/components/application_manager/src/commands/hmi/response_to_hmi.cc8
-rw-r--r--src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc2
-rw-r--r--src/components/application_manager/src/commands/mobile/perform_audio_pass_thru_request.cc1
-rw-r--r--src/components/application_manager/src/commands/mobile/register_app_interface_request.cc111
-rw-r--r--src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc6
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc10
-rw-r--r--src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc4
-rw-r--r--src/components/application_manager/src/helpers/application_helper.cc146
-rw-r--r--src/components/application_manager/src/hmi_command_factory.cc6
-rw-r--r--src/components/application_manager/src/hmi_state.cc112
-rw-r--r--src/components/application_manager/src/message.cc3
-rw-r--r--src/components/application_manager/src/message_helper/message_helper.cc342
-rw-r--r--src/components/application_manager/src/mobile_message_handler.cc3
-rw-r--r--src/components/application_manager/src/policies/policy_handler.cc13
-rw-r--r--src/components/application_manager/src/resumption/resume_ctrl_impl.cc31
-rw-r--r--src/components/application_manager/src/resumption/resumption_data_db.cc11
-rw-r--r--src/components/application_manager/src/resumption/resumption_data_json.cc12
-rw-r--r--src/components/application_manager/src/state_controller_impl.cc44
31 files changed, 1384 insertions, 272 deletions
diff --git a/src/components/application_manager/src/application_impl.cc b/src/components/application_manager/src/application_impl.cc
index 0c864b673d..22a0f2628e 100644
--- a/src/components/application_manager/src/application_impl.cc
+++ b/src/components/application_manager/src/application_impl.cc
@@ -41,9 +41,11 @@
#include "utils/file_system.h"
#include "utils/logger.h"
#include "utils/gen_hash.h"
+#include "utils/shared_ptr.h"
#include "utils/make_shared.h"
#include "utils/timer_task_impl.h"
#include "application_manager/policies/policy_handler_interface.h"
+#include "application_manager/resumption/resume_ctrl.h"
namespace {
@@ -75,10 +77,23 @@ CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager")
namespace application_manager {
+void SwitchApplicationParameters(ApplicationSharedPtr app,
+ const uint32_t app_id,
+ const size_t device_id,
+ const std::string& mac_address) {
+ utils::SharedPtr<ApplicationImpl> application =
+ ApplicationSharedPtr::dynamic_pointer_cast<ApplicationImpl>(app);
+ DCHECK_OR_RETURN_VOID(application);
+ application->app_id_ = app_id;
+ application->device_id_ = device_id;
+ application->mac_address_ = mac_address;
+}
+
ApplicationImpl::ApplicationImpl(
uint32_t application_id,
const std::string& mobile_app_id,
const std::string& mac_address,
+ const connection_handler::DeviceHandle device_id,
const custom_str::CustomString& app_name,
utils::SharedPtr<usage_statistics::StatisticsManager> statistics_manager,
ApplicationManager& application_manager)
@@ -104,13 +119,14 @@ ApplicationImpl::ApplicationImpl(
, put_file_in_none_count_(0)
, delete_file_in_none_count_(0)
, list_files_in_none_count_(0)
- , device_(0)
, mac_address_(mac_address)
+ , device_id_(device_id)
, usage_report_(mobile_app_id, statistics_manager)
, protocol_version_(
protocol_handler::MajorProtocolVersion::PROTOCOL_VERSION_3)
, is_voice_communication_application_(false)
, is_resuming_(false)
+ , is_hash_changed_during_suspend_(false)
, video_stream_retry_number_(0)
, audio_stream_retry_number_(0)
, video_stream_suspend_timer_(
@@ -135,12 +151,6 @@ ApplicationImpl::ApplicationImpl(
SubscribeToButton(mobile_apis::ButtonName::CUSTOM_BUTTON);
// load persistent files
LoadPersistentFiles();
- HmiStatePtr initial_state = application_manager_.CreateRegularState(
- app_id(),
- mobile_apis::HMILevel::INVALID_ENUM,
- mobile_apis::AudioStreamingState::INVALID_ENUM,
- mobile_api::SystemContext::SYSCTXT_MAIN);
- state_.InitState(initial_state);
video_stream_suspend_timeout_ =
application_manager_.get_settings().video_data_stopped_timeout();
@@ -345,7 +355,7 @@ const std::string& ApplicationImpl::bundle_id() const {
}
connection_handler::DeviceHandle ApplicationImpl::device() const {
- return device_;
+ return device_id_;
}
const std::string& ApplicationImpl::mac_address() const {
@@ -605,7 +615,7 @@ void ApplicationImpl::set_app_allowed(const bool allowed) {
}
void ApplicationImpl::set_device(connection_handler::DeviceHandle device) {
- device_ = device;
+ device_id_ = device;
}
uint32_t ApplicationImpl::get_grammar_id() const {
@@ -861,6 +871,10 @@ bool ApplicationImpl::is_application_data_changed() const {
return is_application_data_changed_;
}
+void ApplicationImpl::SetInitialState(HmiStatePtr state) {
+ state_.InitState(state);
+}
+
void ApplicationImpl::set_is_application_data_changed(
bool state_application_data) {
is_application_data_changed_ = state_application_data;
@@ -872,7 +886,19 @@ void ApplicationImpl::UpdateHash() {
utils::gen_hash(application_manager_.get_settings().hash_string_size());
set_is_application_data_changed(true);
- MessageHelper::SendHashUpdateNotification(app_id(), application_manager_);
+ if (!application_manager_.resume_controller().is_suspended()) {
+ MessageHelper::SendHashUpdateNotification(app_id(), application_manager_);
+ } else {
+ is_hash_changed_during_suspend_ = true;
+ }
+}
+
+bool ApplicationImpl::IsHashChangedDuringSuspend() const {
+ return is_hash_changed_during_suspend_;
+}
+
+void ApplicationImpl::SetHashChangedDuringSuspend(const bool state) {
+ is_hash_changed_during_suspend_ = state;
}
void ApplicationImpl::CleanupFiles() {
diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc
index 9d656331a5..a2703aca75 100644
--- a/src/components/application_manager/src/application_manager_impl.cc
+++ b/src/components/application_manager/src/application_manager_impl.cc
@@ -50,8 +50,10 @@
#include "application_manager/app_launch/app_launch_ctrl_impl.h"
#include "application_manager/app_launch/app_launch_data_db.h"
#include "application_manager/app_launch/app_launch_data_json.h"
+#include "application_manager/helpers/application_helper.h"
#include "protocol_handler/protocol_handler.h"
#include "hmi_message_handler/hmi_message_handler.h"
+#include "application_manager/command_holder_impl.h"
#include "connection_handler/connection_handler_impl.h"
#include "formatters/formatter_json_rpc.h"
#include "formatters/CFormatterJsonSDLRPCv2.h"
@@ -93,9 +95,40 @@ DeviceTypes devicesType = {
hmi_apis::Common_TransportType::USB_IOS),
std::make_pair(std::string("BLUETOOTH"),
hmi_apis::Common_TransportType::BLUETOOTH),
+ std::make_pair(std::string("BLUETOOTH_IOS"),
+ hmi_apis::Common_TransportType::BLUETOOTH),
std::make_pair(std::string("WIFI"), hmi_apis::Common_TransportType::WIFI)};
}
+/**
+ * @brief device_id_comparator is predicate to compare application device id
+ * @param device_id Device id to compare with
+ * @param app Application pointer
+ * @return True if device id of application matches to device id passed
+ */
+bool device_id_comparator(const std::string& device_id,
+ ApplicationSharedPtr app) {
+ DCHECK_OR_RETURN(app, false);
+ LOG4CXX_DEBUG(logger_,
+ "Data to compare: device_id : " << device_id << " app mac: "
+ << app->mac_address());
+
+ return device_id == app->mac_address();
+}
+
+/**
+ * @brief policy_app_id_comparator is predicate to compare policy application
+ * ids
+ * @param policy_app_id Policy id of application
+ * @param app Application pointer
+ * @return True if policy id of application matches to policy id passed
+ */
+bool policy_app_id_comparator(const std::string& policy_app_id,
+ ApplicationSharedPtr app) {
+ DCHECK_OR_RETURN(app, false);
+ return app->policy_app_id() == policy_app_id;
+}
+
uint32_t ApplicationManagerImpl::corelation_id_ = 0;
const uint32_t ApplicationManagerImpl::max_corelation_id_ = UINT_MAX;
@@ -165,6 +198,7 @@ ApplicationManagerImpl::ApplicationManagerImpl(
const uint32_t timeout_ms = 10000u;
clearing_timer->Start(timeout_ms, timer::kSingleShot);
timer_pool_.push_back(clearing_timer);
+ commands_holder_.reset(new CommandHolderImpl(*this));
}
ApplicationManagerImpl::~ApplicationManagerImpl() {
@@ -194,33 +228,6 @@ ApplicationManagerImpl::~ApplicationManagerImpl() {
navi_app_to_end_stream_.clear();
}
-template <class UnaryPredicate>
-ApplicationSharedPtr FindApp(DataAccessor<ApplicationSet> accessor,
- UnaryPredicate finder) {
- ApplicationSet::iterator it = std::find_if(
- accessor.GetData().begin(), accessor.GetData().end(), finder);
- if (accessor.GetData().end() == it) {
- LOG4CXX_DEBUG(logger_, "Unable to find application");
- return ApplicationSharedPtr();
- }
- ApplicationSharedPtr app = *it;
- LOG4CXX_DEBUG(logger_, " Found Application app_id = " << app->app_id());
- return app;
-}
-
-template <class UnaryPredicate>
-std::vector<ApplicationSharedPtr> FindAllApps(
- DataAccessor<ApplicationSet> accessor, UnaryPredicate finder) {
- std::vector<ApplicationSharedPtr> result;
- ApplicationSetConstIt it = std::find_if(
- accessor.GetData().begin(), accessor.GetData().end(), finder);
- while (it != accessor.GetData().end()) {
- result.push_back(*it);
- it = std::find_if(++it, accessor.GetData().end(), finder);
- }
- return result;
-}
-
DataAccessor<ApplicationSet> ApplicationManagerImpl::applications() const {
DataAccessor<ApplicationSet> accessor(applications_, applications_list_lock_);
return accessor;
@@ -331,15 +338,6 @@ ApplicationManagerImpl::applications_by_button(uint32_t button) {
return FindAllApps(accessor, finder);
}
-struct SubscribedToIVIPredicate {
- int32_t vehicle_info_;
- SubscribedToIVIPredicate(int32_t vehicle_info)
- : vehicle_info_(vehicle_info) {}
- bool operator()(const ApplicationSharedPtr app) const {
- return app ? app->IsSubscribedToIVI(vehicle_info_) : false;
- }
-};
-
struct IsApplication {
IsApplication(connection_handler::DeviceHandle device_handle,
const std::string& policy_app_id)
@@ -366,7 +364,7 @@ std::vector<ApplicationSharedPtr> ApplicationManagerImpl::IviInfoUpdated(
break;
}
- SubscribedToIVIPredicate finder(static_cast<int32_t>(vehicle_info));
+ SubscribedToIVIPredicate finder(vehicle_info);
DataAccessor<ApplicationSet> accessor = applications();
return FindAllApps(accessor, finder);
}
@@ -394,6 +392,12 @@ void ApplicationManagerImpl::OnApplicationRegistered(ApplicationSharedPtr app) {
event.raise(event_dispatcher());
}
+void ApplicationManagerImpl::OnApplicationSwitched(ApplicationSharedPtr app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ commands_holder_->Resume(app, CommandHolder::CommandType::kMobileCommand);
+ commands_holder_->Resume(app, CommandHolder::CommandType::kHmiCommand);
+}
+
bool ApplicationManagerImpl::IsAppTypeExistsInFullOrLimited(
ApplicationConstSharedPtr app) const {
bool voice_state = app->is_voice_communication_supported();
@@ -473,10 +477,10 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
// original app_id can be received via ApplicationImpl::mobile_app_id()
uint32_t app_id = 0;
std::list<int32_t> sessions_list;
- uint32_t device_id = 0;
+ connection_handler::DeviceHandle device_id = 0;
DCHECK_OR_RETURN(connection_handler_, ApplicationSharedPtr());
- if (connection_handler().GetDataOnSessionKey(
+ if (connection_handler().get_session_observer().GetDataOnSessionKey(
connection_key, &app_id, &sessions_list, &device_id) == -1) {
LOG4CXX_ERROR(logger_, "Failed to create application: no connection info.");
utils::SharedPtr<smart_objects::SmartObject> response(
@@ -489,6 +493,20 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
return ApplicationSharedPtr();
}
+ smart_objects::SmartObject& params = message[strings::msg_params];
+ const std::string& policy_app_id = params[strings::app_id].asString();
+ const custom_str::CustomString& app_name =
+ message[strings::msg_params][strings::app_name].asCustomString();
+ std::string device_mac;
+ std::string connection_type;
+ if (connection_handler().get_session_observer().GetDataOnDeviceID(
+ device_id, NULL, NULL, &device_mac, &connection_type) == -1) {
+ LOG4CXX_DEBUG(logger_, "Failed to extract device mac for id " << device_id);
+ } else {
+ LOG4CXX_DEBUG(logger_,
+ "Device mac for id" << device_id << " is " << device_mac);
+ }
+
LOG4CXX_DEBUG(logger_, "Restarting application list update timer");
GetPolicyHandler().OnAppsSearchStarted();
uint32_t timeout = get_settings().application_list_update_timeout();
@@ -507,22 +525,11 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
return ApplicationSharedPtr();
}
- smart_objects::SmartObject& params = message[strings::msg_params];
- const std::string& policy_app_id = params[strings::app_id].asString();
- const custom_str::CustomString& app_name =
- message[strings::msg_params][strings::app_name].asCustomString();
- std::string device_mac = "";
- if (connection_handler().get_session_observer().GetDataOnDeviceID(
- device_id, NULL, NULL, &device_mac, NULL) == -1) {
- LOG4CXX_ERROR(logger_, "Failed to extract device mac for id " << device_id);
- } else {
- LOG4CXX_DEBUG(logger_,
- "Device mac for id" << device_id << " is " << device_mac);
- }
ApplicationSharedPtr application(
new ApplicationImpl(app_id,
policy_app_id,
device_mac,
+ device_id,
app_name,
GetPolicyHandler().GetStatisticManager(),
*this));
@@ -537,12 +544,19 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
return ApplicationSharedPtr();
}
+ HmiStatePtr initial_state =
+ CreateRegularState(utils::SharedPtr<Application>(application),
+ mobile_apis::HMILevel::INVALID_ENUM,
+ mobile_apis::AudioStreamingState::INVALID_ENUM,
+ mobile_api::SystemContext::SYSCTXT_MAIN);
+
+ application->SetInitialState(initial_state);
+
application->set_folder_name(policy_app_id + "_" +
application->mac_address());
// To load persistent files, app folder name must be known first, which is now
// depends on device_id and mobile_app_id
application->LoadPersistentFiles();
- application->set_device(device_id);
application->set_grammar_id(GenerateGrammarID());
mobile_api::Language::eType launguage_desired =
@@ -627,11 +641,13 @@ ApplicationSharedPtr ApplicationManagerImpl::RegisterApplication(
return application;
}
-bool ApplicationManagerImpl::RemoveAppDataFromHMI(ApplicationSharedPtr app) {
+DEPRECATED bool ApplicationManagerImpl::RemoveAppDataFromHMI(
+ ApplicationSharedPtr app) {
return true;
}
-bool ApplicationManagerImpl::LoadAppDataToHMI(ApplicationSharedPtr app) {
+DEPRECATED bool ApplicationManagerImpl::LoadAppDataToHMI(
+ ApplicationSharedPtr app) {
return true;
}
@@ -788,7 +804,8 @@ void ApplicationManagerImpl::set_driver_distraction_state(
driver_distraction_state_ = state;
}
-void ApplicationManagerImpl::set_vr_session_started(const bool state) {
+DEPRECATED void ApplicationManagerImpl::set_vr_session_started(
+ const bool state) {
is_vr_session_strated_ = state;
}
@@ -797,6 +814,18 @@ void ApplicationManagerImpl::SetAllAppsAllowed(const bool allowed) {
}
HmiStatePtr ApplicationManagerImpl::CreateRegularState(
+ utils::SharedPtr<Application> app,
+ mobile_apis::HMILevel::eType hmi_level,
+ mobile_apis::AudioStreamingState::eType audio_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_system_context(system_context);
+ return state;
+}
+
+HmiStatePtr ApplicationManagerImpl::CreateRegularState(
uint32_t app_id,
mobile_apis::HMILevel::eType hmi_level,
mobile_apis::AudioStreamingState::eType audio_state,
@@ -1053,6 +1082,105 @@ void ApplicationManagerImpl::RemoveDevice(
LOG4CXX_DEBUG(logger_, "device_handle " << device_handle);
}
+void ApplicationManagerImpl::OnDeviceSwitchingStart(
+ const connection_handler::Device& device_from,
+ const connection_handler::Device& device_to) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ {
+ auto apps_data_accessor = applications();
+
+ std::copy_if(apps_data_accessor.GetData().begin(),
+ apps_data_accessor.GetData().end(),
+ std::back_inserter(reregister_wait_list_),
+ std::bind1st(std::ptr_fun(&device_id_comparator),
+ device_from.mac_address()));
+ }
+
+ {
+ // During sending of UpdateDeviceList this lock is acquired also so making
+ // it scoped
+ sync_primitives::AutoLock lock(reregister_wait_list_lock_);
+ for (auto i = reregister_wait_list_.begin();
+ reregister_wait_list_.end() != i;
+ ++i) {
+ auto app = *i;
+ request_ctrl_.terminateAppRequests(app->app_id());
+ resume_ctrl_->SaveApplication(app);
+ }
+ }
+
+ policy_handler_->OnDeviceSwitching(device_from.mac_address(),
+ device_to.mac_address());
+
+ connection_handler::DeviceMap device_list;
+ device_list.insert(std::make_pair(device_to.device_handle(), device_to));
+
+ smart_objects::SmartObjectSPtr msg_params =
+ MessageHelper::CreateDeviceListSO(device_list, GetPolicyHandler(), *this);
+ if (!msg_params) {
+ LOG4CXX_ERROR(logger_, "Can't create UpdateDeviceList notification");
+ return;
+ }
+
+ auto update_list = utils::MakeShared<smart_objects::SmartObject>();
+ smart_objects::SmartObject& so_to_send = *update_list;
+ so_to_send[jhs::S_PARAMS][jhs::S_FUNCTION_ID] =
+ hmi_apis::FunctionID::BasicCommunication_UpdateDeviceList;
+ so_to_send[jhs::S_PARAMS][jhs::S_MESSAGE_TYPE] =
+ hmi_apis::messageType::request;
+ so_to_send[jhs::S_PARAMS][jhs::S_PROTOCOL_VERSION] = 2;
+ so_to_send[jhs::S_PARAMS][jhs::S_PROTOCOL_TYPE] = 1;
+ so_to_send[jhs::S_PARAMS][jhs::S_CORRELATION_ID] = GetNextHMICorrelationID();
+ so_to_send[jhs::S_MSG_PARAMS] = *msg_params;
+ ManageHMICommand(update_list);
+}
+
+void ApplicationManagerImpl::OnDeviceSwitchingFinish(
+ const std::string& device_uid) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ UNUSED(device_uid);
+ sync_primitives::AutoLock lock(reregister_wait_list_lock_);
+
+ const bool unexpected_disonnect = true;
+ const bool is_resuming = true;
+ for (auto app_it = reregister_wait_list_.begin();
+ app_it != reregister_wait_list_.end();
+ ++app_it) {
+ auto app = *app_it;
+ UnregisterApplication(app->app_id(),
+ mobile_apis::Result::INVALID_ENUM,
+ is_resuming,
+ unexpected_disonnect);
+ }
+ reregister_wait_list_.clear();
+}
+
+void ApplicationManagerImpl::SwitchApplication(ApplicationSharedPtr app,
+ const uint32_t connection_key,
+ const size_t device_id,
+ const std::string& mac_address) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN_VOID(app);
+ sync_primitives::AutoLock lock(applications_list_lock_);
+ DCHECK_OR_RETURN_VOID(1 == applications_.erase(app));
+
+ LOG4CXX_DEBUG(logger_,
+ "Changing app id to " << connection_key
+ << ". Changing device id to "
+ << device_id);
+
+ SwitchApplicationParameters(app, connection_key, device_id, mac_address);
+
+ // Normally this is done during registration, however since switched apps are
+ // not being registered again need to set protocol version on session.
+ connection_handler().BindProtocolVersionWithSession(
+ connection_key, static_cast<uint8_t>(app->protocol_version()));
+
+ // Application need to be re-inserted in order to keep sorting in applications
+ // container. Otherwise data loss on erasing is possible.
+ applications_.insert(app);
+}
+
mobile_apis::HMILevel::eType ApplicationManagerImpl::GetDefaultHmiLevel(
ApplicationConstSharedPtr application) const {
using namespace mobile_apis;
@@ -1175,7 +1303,6 @@ void ApplicationManagerImpl::ReplaceHMIByMobileAppId(
}
}
-// DEPRECATED
bool ApplicationManagerImpl::StartNaviService(
uint32_t app_id, protocol_handler::ServiceType service_type) {
using namespace protocol_handler;
@@ -1347,7 +1474,9 @@ void ApplicationManagerImpl::StopNaviService(
app->StopStreaming(service_type);
}
-// DEPRECATED
+// Suppress warning for deprecated method used within another deprecated method
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
bool ApplicationManagerImpl::OnServiceStartedCallback(
const connection_handler::DeviceHandle& device_handle,
const int32_t& session_key,
@@ -1383,6 +1512,7 @@ bool ApplicationManagerImpl::OnServiceStartedCallback(
}
return false;
}
+#pragma GCC diagnostic pop
void ApplicationManagerImpl::OnServiceStartedCallback(
const connection_handler::DeviceHandle& device_handle,
@@ -1441,6 +1571,17 @@ void ApplicationManagerImpl::OnServiceEndedCallback(
<< type << " with reason " << close_reason
<< " in session 0x" << std::hex << session_key);
+ auto app = application(static_cast<uint32_t>(session_key));
+ if (!app) {
+ return;
+ }
+
+ if (IsAppInReconnectMode(app->policy_app_id())) {
+ LOG4CXX_DEBUG(logger_,
+ "Application is in reconnection list and won't be closed.");
+ return;
+ }
+
if (type == kRpc) {
LOG4CXX_INFO(logger_, "Remove application.");
/* In case it was unexpected disconnect or some special case
@@ -1523,6 +1664,12 @@ void ApplicationManagerImpl::OnCertificateUpdateRequired() {
GetPolicyHandler().OnPTExchangeNeeded();
}
+bool ApplicationManagerImpl::GetPolicyCertificateData(std::string& data) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ data = GetPolicyHandler().RetrieveCertificate();
+ return true;
+}
+
security_manager::SSLContext::HandshakeContext
ApplicationManagerImpl::GetHandshakeContext(uint32_t key) const {
LOG4CXX_AUTO_TRACE(logger_);
@@ -1534,6 +1681,15 @@ ApplicationManagerImpl::GetHandshakeContext(uint32_t key) const {
}
return SSLContext::HandshakeContext();
}
+
+bool ApplicationManagerImpl::CheckAppIsNavi(const uint32_t app_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ ApplicationSharedPtr app = application(app_id);
+ if (app) {
+ return app->is_navi();
+ }
+ return false;
+}
#endif // ENABLE_SECURITY
void ApplicationManagerImpl::set_hmi_message_handler(
@@ -1726,6 +1882,16 @@ bool ApplicationManagerImpl::ManageMobileCommand(
return false;
}
+ const uint32_t connection_key = static_cast<uint32_t>(
+ (*message)[strings::params][strings::connection_key].asUInt());
+
+ auto app_ptr = application(connection_key);
+ if (app_ptr && IsAppInReconnectMode(app_ptr->policy_app_id())) {
+ commands_holder_->Suspend(
+ app_ptr, CommandHolder::CommandType::kMobileCommand, message);
+ return true;
+ }
+
mobile_apis::FunctionID::eType function_id =
static_cast<mobile_apis::FunctionID::eType>(
(*message)[strings::params][strings::function_id].asInt());
@@ -1736,9 +1902,6 @@ bool ApplicationManagerImpl::ManageMobileCommand(
? (*message)[strings::params][strings::correlation_id].asUInt()
: 0;
- uint32_t connection_key =
- (*message)[strings::params][strings::connection_key].asUInt();
-
int32_t protocol_type =
(*message)[strings::params][strings::protocol_type].asUInt();
@@ -1955,8 +2118,21 @@ bool ApplicationManagerImpl::ManageHMICommand(
return false;
}
+ if ((*message).keyExists(strings::msg_params) &&
+ (*message)[strings::msg_params].keyExists(strings::app_id)) {
+ const auto connection_key =
+ (*message)[strings::msg_params][strings::app_id].asUInt();
+
+ auto app = application(static_cast<uint32_t>(connection_key));
+ if (app && IsAppInReconnectMode(app->policy_app_id())) {
+ commands_holder_->Suspend(
+ app, CommandHolder::CommandType::kHmiCommand, message);
+ return true;
+ }
+ }
+
int32_t message_type =
- (*(message.get()))[strings::params][strings::message_type].asInt();
+ (*message)[strings::params][strings::message_type].asInt();
if (kRequest == message_type) {
LOG4CXX_DEBUG(logger_, "ManageHMICommand");
@@ -1967,9 +2143,9 @@ bool ApplicationManagerImpl::ManageHMICommand(
command->Run();
if (kResponse == message_type) {
const uint32_t correlation_id =
- (*(message.get()))[strings::params][strings::correlation_id].asUInt();
+ (*message)[strings::params][strings::correlation_id].asUInt();
const int32_t function_id =
- (*(message.get()))[strings::params][strings::function_id].asInt();
+ (*message)[strings::params][strings::function_id].asInt();
request_ctrl_.OnHMIResponse(correlation_id, function_id);
}
return true;
@@ -2091,9 +2267,12 @@ bool ApplicationManagerImpl::ConvertMessageToSO(
message.function_id(),
message.type(),
message.correlation_id());
+
+ rpc::ValidationReport report("RPC");
+
if (!conversion_result ||
!mobile_so_factory().attachSchema(output, true) ||
- ((output.validate() != smart_objects::Errors::OK))) {
+ ((output.validate(&report) != smart_objects::Errors::OK))) {
LOG4CXX_WARN(logger_,
"Failed to parse string to smart object :"
<< message.json_message());
@@ -2103,6 +2282,9 @@ bool ApplicationManagerImpl::ConvertMessageToSO(
message.function_id(),
message.correlation_id(),
mobile_apis::Result::INVALID_DATA));
+
+ (*response)[strings::msg_params][strings::info] =
+ rpc::PrettyFormat(report);
ManageMobileCommand(response, commands::Command::ORIGIN_SDL);
return false;
}
@@ -2150,8 +2332,18 @@ bool ApplicationManagerImpl::ConvertMessageToSO(
LOG4CXX_WARN(logger_, "Failed to attach schema to object.");
return false;
}
- if (output.validate() != smart_objects::Errors::OK) {
- LOG4CXX_ERROR(logger_, "Incorrect parameter from HMI");
+
+ rpc::ValidationReport report("RPC");
+
+ if (output.validate(&report) != smart_objects::Errors::OK) {
+ LOG4CXX_ERROR(logger_,
+ "Incorrect parameter from HMI"
+ << rpc::PrettyFormat(report));
+
+ output.erase(strings::msg_params);
+ output[strings::params][hmi_response::code] =
+ hmi_apis::Common_Result::INVALID_DATA;
+ output[strings::msg_params][strings::info] = rpc::PrettyFormat(report);
return false;
}
break;
@@ -2291,7 +2483,7 @@ bool ApplicationManagerImpl::ConvertSOtoMessage(
}
if (message.getElement(jhs::S_PARAMS).keyExists(strings::binary_data)) {
- application_manager::BinaryData binaryData(
+ const application_manager::BinaryData binaryData(
message.getElement(jhs::S_PARAMS)
.getElement(strings::binary_data)
.asBinary());
@@ -2327,8 +2519,11 @@ MessageValidationResult ApplicationManagerImpl::ValidateMessageBySchema(
if (!mobile_so_factory().attachSchema(so, true)) {
return INVALID_METADATA;
}
-
- if (so.validate() != smart_objects::Errors::OK) {
+ rpc::ValidationReport report("RPC");
+ if (so.validate(&report) != smart_objects::Errors::OK) {
+ LOG4CXX_WARN(logger_,
+ "validate() failed for Mobile message - "
+ << rpc::PrettyFormat(report));
return SCHEMA_MISMATCH;
}
break;
@@ -2347,7 +2542,11 @@ MessageValidationResult ApplicationManagerImpl::ValidateMessageBySchema(
return INVALID_METADATA;
}
- if (so.validate() != smart_objects::Errors::OK) {
+ rpc::ValidationReport report("RPC");
+ if (so.validate(&report) != smart_objects::Errors::OK) {
+ LOG4CXX_WARN(logger_,
+ "validate() failed for HMI message - "
+ << rpc::PrettyFormat(report));
return SCHEMA_MISMATCH;
}
break;
@@ -2595,10 +2794,10 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array,
const std::string app_icon_dir(settings_.app_icons_folder());
const std::string full_icon_path(app_icon_dir + "/" + policy_app_id);
- uint32_t device_id = 0;
+ connection_handler::DeviceHandle device_id = 0;
if (-1 ==
- connection_handler().GetDataOnSessionKey(
+ connection_handler().get_session_observer().GetDataOnSessionKey(
connection_key, NULL, NULL, &device_id)) {
LOG4CXX_ERROR(logger_,
"Failed to create application: no connection info.");
@@ -2620,6 +2819,7 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array,
new ApplicationImpl(0,
policy_app_id,
device_mac,
+ device_id,
appName,
GetPolicyHandler().GetStatisticManager(),
*this));
@@ -2628,7 +2828,6 @@ void ApplicationManagerImpl::CreateApplications(SmartArray& obj_array,
app->SetPackageName(package_name);
app->set_app_icon_path(full_icon_path);
app->set_hmi_application_id(hmi_app_id);
- app->set_device(device_id);
app->set_vr_synonyms(vrSynonym);
app->set_tts_name(ttsName);
@@ -2891,7 +3090,7 @@ void ApplicationManagerImpl::UnregisterAllApplications() {
}
}
if (is_ignition_off) {
- resume_controller().OnSuspend();
+ resume_controller().OnIgnitionOff();
}
request_ctrl_.terminateAllHMIRequests();
}
@@ -2983,13 +3182,14 @@ void ApplicationManagerImpl::UnregisterApplication(
ApplicationSharedPtr app_to_remove;
connection_handler::DeviceHandle handle = 0;
{
- DataAccessor<ApplicationSet> accessor(applications());
- ApplicationSetConstIt it = accessor.GetData().begin();
- for (; it != accessor.GetData().end(); ++it) {
- if ((*it)->app_id() == app_id) {
- app_to_remove = *it;
- handle = app_to_remove->device();
- break;
+ sync_primitives::AutoLock lock(applications_list_lock_);
+ auto it_app = applications_.begin();
+ while (applications_.end() != it_app) {
+ if (app_id == (*it_app)->app_id()) {
+ app_to_remove = *it_app;
+ applications_.erase(it_app++);
+ } else {
+ ++it_app;
}
}
if (!app_to_remove) {
@@ -3007,11 +3207,10 @@ void ApplicationManagerImpl::UnregisterApplication(
} else {
resume_controller().RemoveApplicationFromSaved(app_to_remove);
}
- applications_.erase(app_to_remove);
(hmi_capabilities_->get_hmi_language_handler())
.OnUnregisterApplication(app_id);
AppV4DevicePredicate finder(handle);
- ApplicationSharedPtr app = FindApp(accessor, finder);
+ ApplicationSharedPtr app = FindApp(applications(), finder);
if (!app) {
LOG4CXX_DEBUG(
logger_, "There is no more SDL4 apps with device handle: " << handle);
@@ -3020,6 +3219,9 @@ void ApplicationManagerImpl::UnregisterApplication(
SendUpdateAppList();
}
}
+
+ commands_holder_->Clear(app_to_remove);
+
if (audio_pass_thru_active_) {
// May be better to put this code in MessageHelper?
EndAudioPassThrough();
@@ -3242,8 +3444,9 @@ bool ApplicationManagerImpl::IsLowVoltage() {
std::string ApplicationManagerImpl::GetHashedAppID(
uint32_t connection_key, const std::string& mobile_app_id) const {
- uint32_t device_id = 0;
- connection_handler().GetDataOnSessionKey(connection_key, 0, NULL, &device_id);
+ connection_handler::DeviceHandle device_id = 0;
+ connection_handler().get_session_observer().GetDataOnSessionKey(
+ connection_key, 0, NULL, &device_id);
std::string device_name;
connection_handler().get_session_observer().GetDataOnDeviceID(
device_id, &device_name, NULL, NULL, NULL);
@@ -3639,6 +3842,17 @@ bool ApplicationManagerImpl::IsApplicationForbidden(
return forbidden_applications.find(name) != forbidden_applications.end();
}
+bool ApplicationManagerImpl::IsAppInReconnectMode(
+ const std::string& policy_app_id) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock lock(reregister_wait_list_lock_);
+ return reregister_wait_list_.end() !=
+ std::find_if(reregister_wait_list_.begin(),
+ reregister_wait_list_.end(),
+ std::bind1st(std::ptr_fun(&policy_app_id_comparator),
+ policy_app_id));
+}
+
policy::DeviceConsent ApplicationManagerImpl::GetUserConsentForDevice(
const std::string& device_id) const {
return GetPolicyHandler().GetUserConsentForDevice(device_id);
@@ -3922,6 +4136,48 @@ void ApplicationManagerImpl::OnUpdateHMIAppType(
}
}
+void ApplicationManagerImpl::EraseAppFromReconnectionList(
+ const ApplicationSharedPtr& app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ if (!app) {
+ LOG4CXX_WARN(logger_, "Application is not valid.");
+ return;
+ }
+
+ const auto policy_app_id = app->policy_app_id();
+ sync_primitives::AutoLock lock(reregister_wait_list_lock_);
+ auto app_it = std::find_if(
+ reregister_wait_list_.begin(),
+ reregister_wait_list_.end(),
+ std::bind1st(std::ptr_fun(&policy_app_id_comparator), policy_app_id));
+ if (reregister_wait_list_.end() != app_it) {
+ reregister_wait_list_.erase(app_it);
+ }
+}
+
+void ApplicationManagerImpl::ProcessReconnection(
+ ApplicationSharedPtr application, const uint32_t connection_key) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN_VOID(application);
+
+ connection_handler::DeviceHandle new_device_id = 0;
+ connection_handler().get_session_observer().GetDataOnSessionKey(
+ connection_key, NULL, NULL, &new_device_id);
+ DCHECK_OR_RETURN_VOID(new_device_id);
+
+ std::string device_mac;
+ std::string connection_type;
+ connection_handler().get_session_observer().GetDataOnDeviceID(
+ new_device_id, NULL, NULL, &device_mac, &connection_type);
+
+ EraseAppFromReconnectionList(application);
+
+ SwitchApplication(application, connection_key, new_device_id, device_mac);
+
+ // Update connection type for existed device.
+ GetPolicyHandler().AddDevice(device_mac, connection_type);
+}
+
void ApplicationManagerImpl::OnPTUFinished(const bool ptu_result) {
#ifdef SDL_REMOTE_CONTROL
if (!ptu_result) {
@@ -4044,9 +4300,46 @@ void ApplicationManagerImpl::UnsubscribeAppFromWayPoints(
subscribed_way_points_apps_list_.erase(app_id);
}
+bool ApplicationManagerImpl::IsAppSubscribedForWayPoints(
+ ApplicationSharedPtr app) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_);
+ LOG4CXX_DEBUG(logger_,
+ "There are applications subscribed: "
+ << subscribed_way_points_apps_list_.size());
+ if (subscribed_way_points_apps_list_.find(app) ==
+ subscribed_way_points_apps_list_.end()) {
+ return false;
+ }
+ return true;
+}
+
+void ApplicationManagerImpl::SubscribeAppForWayPoints(
+ ApplicationSharedPtr app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_);
+ subscribed_way_points_apps_list_.insert(app);
+ LOG4CXX_DEBUG(logger_,
+ "There are applications subscribed: "
+ << subscribed_way_points_apps_list_.size());
+}
+
+void ApplicationManagerImpl::UnsubscribeAppFromWayPoints(
+ ApplicationSharedPtr app) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_);
+ subscribed_way_points_apps_list_.erase(app);
+ LOG4CXX_DEBUG(logger_,
+ "There are applications subscribed: "
+ << subscribed_way_points_apps_list_.size());
+}
+
bool ApplicationManagerImpl::IsAnyAppSubscribedForWayPoints() const {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(subscribed_way_points_apps_lock_);
+ LOG4CXX_DEBUG(logger_,
+ "There are applications subscribed: "
+ << subscribed_way_points_apps_list_.size());
return !subscribed_way_points_apps_list_.empty();
}
diff --git a/src/components/application_manager/src/command_holder_impl.cc b/src/components/application_manager/src/command_holder_impl.cc
new file mode 100644
index 0000000000..4e2cf89f57
--- /dev/null
+++ b/src/components/application_manager/src/command_holder_impl.cc
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2017, 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/command_holder_impl.h"
+#include "application_manager/application_manager.h"
+#include "application_manager/commands/command.h"
+
+namespace application_manager {
+CREATE_LOGGERPTR_GLOBAL(logger_, "ApplicationManager")
+
+CommandHolderImpl::CommandHolderImpl(ApplicationManager& app_manager)
+ : app_manager_(app_manager) {}
+
+void CommandHolderImpl::Suspend(
+ ApplicationSharedPtr application,
+ CommandType type,
+ utils::SharedPtr<smart_objects::SmartObject> command) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN_VOID(application);
+ LOG4CXX_DEBUG(logger_,
+ "Suspending command(s) for application: "
+ << application->policy_app_id());
+ sync_primitives::AutoLock lock(commands_lock_);
+
+ if (CommandType::kHmiCommand == type) {
+ app_hmi_commands_[application].push_back(command);
+ LOG4CXX_DEBUG(logger_,
+ "Suspended HMI command(s): " << app_hmi_commands_.size());
+ } else {
+ app_mobile_commands_[application].push_back(command);
+ LOG4CXX_DEBUG(logger_,
+ "Suspended mobile command(s): " << app_hmi_commands_.size());
+ }
+}
+
+void CommandHolderImpl::Resume(ApplicationSharedPtr application,
+ CommandType type) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN_VOID(application);
+ LOG4CXX_DEBUG(
+ logger_,
+ "Resuming command(s) for application: " << application->policy_app_id());
+ if (CommandType::kHmiCommand == type) {
+ ResumeHmiCommand(application);
+ } else {
+ ResumeMobileCommand(application);
+ }
+}
+
+void CommandHolderImpl::Clear(ApplicationSharedPtr application) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN_VOID(application);
+ LOG4CXX_DEBUG(
+ logger_,
+ "Clearing command(s) for application: " << application->policy_app_id());
+ sync_primitives::AutoLock lock(commands_lock_);
+ auto app_hmi_commands = app_hmi_commands_.find(application);
+ if (app_hmi_commands_.end() != app_hmi_commands) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "Clearing HMI command(s): " << app_hmi_commands->second.size());
+ app_hmi_commands_.erase(app_hmi_commands);
+ }
+
+ auto app_mobile_commands = app_mobile_commands_.find(application);
+ if (app_mobile_commands_.end() != app_mobile_commands) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "Clearing mobile command(s): " << app_mobile_commands->second.size());
+ app_mobile_commands_.erase(app_mobile_commands);
+ }
+}
+
+void CommandHolderImpl::ResumeHmiCommand(ApplicationSharedPtr application) {
+ DCHECK_OR_RETURN_VOID(application);
+ sync_primitives::AutoLock lock(commands_lock_);
+ auto app_commands = app_hmi_commands_.find(application);
+ if (app_hmi_commands_.end() == app_commands) {
+ return;
+ }
+
+ LOG4CXX_DEBUG(logger_,
+ "Resuming HMI command(s): " << app_hmi_commands_.size());
+
+ for (auto cmd : app_commands->second) {
+ (*cmd)[strings::msg_params][strings::app_id] = application->hmi_app_id();
+ app_manager_.ManageHMICommand(cmd);
+ }
+
+ app_hmi_commands_.erase(app_commands);
+}
+
+void CommandHolderImpl::ResumeMobileCommand(ApplicationSharedPtr application) {
+ DCHECK_OR_RETURN_VOID(application);
+ sync_primitives::AutoLock lock(commands_lock_);
+ auto app_commands = app_mobile_commands_.find(application);
+ if (app_mobile_commands_.end() == app_commands) {
+ return;
+ }
+
+ LOG4CXX_DEBUG(logger_,
+ "Resuming mobile command(s): " << app_mobile_commands_.size());
+
+ for (auto cmd : app_commands->second) {
+ (*cmd)[strings::params][strings::connection_key] = application->app_id();
+ app_manager_.ManageMobileCommand(
+ cmd, commands::Command::CommandOrigin::ORIGIN_MOBILE);
+ }
+
+ app_mobile_commands_.erase(app_commands);
+}
+} // application_manager
diff --git a/src/components/application_manager/src/commands/command_impl.cc b/src/components/application_manager/src/commands/command_impl.cc
index 0a3e65a790..b928184148 100644
--- a/src/components/application_manager/src/commands/command_impl.cc
+++ b/src/components/application_manager/src/commands/command_impl.cc
@@ -94,25 +94,30 @@ void CommandImpl::SetAllowedToTerminate(const bool allowed) {
allowed_to_terminate_ = allowed;
}
-void CommandImpl::ReplaceMobileByHMIAppId(
+bool CommandImpl::ReplaceMobileWithHMIAppId(
NsSmartDeviceLink::NsSmartObjects::SmartObject& message) {
+ LOG4CXX_AUTO_TRACE(logger_);
if (message.keyExists(strings::app_id)) {
ApplicationSharedPtr application =
application_manager_.application(message[strings::app_id].asUInt());
- if (application.valid()) {
- LOG4CXX_DEBUG(logger_,
- "ReplaceMobileByHMIAppId from "
- << message[strings::app_id].asInt() << " to "
- << application->hmi_app_id());
- message[strings::app_id] = application->hmi_app_id();
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "Substitution mobile --> HMI id is failed.");
+ return false;
}
+ LOG4CXX_DEBUG(logger_,
+ "ReplaceMobileWithHMIAppId from "
+ << message[strings::app_id].asInt() << " to "
+ << application->hmi_app_id());
+ message[strings::app_id] = application->hmi_app_id();
} else {
switch (message.getType()) {
case smart_objects::SmartType::SmartType_Array: {
smart_objects::SmartArray* message_array = message.asArray();
smart_objects::SmartArray::iterator it = message_array->begin();
for (; it != message_array->end(); ++it) {
- ReplaceMobileByHMIAppId(*it);
+ if (!ReplaceMobileWithHMIAppId(*it)) {
+ break;
+ }
}
break;
}
@@ -121,36 +126,51 @@ void CommandImpl::ReplaceMobileByHMIAppId(
std::set<std::string>::const_iterator key = keys.begin();
for (; key != keys.end(); ++key) {
std::string k = *key;
- ReplaceMobileByHMIAppId(message[*key]);
+ if (!ReplaceMobileWithHMIAppId(message[*key])) {
+ break;
+ }
}
break;
}
default: { break; }
}
}
+
+ return true;
+}
+
+DEPRECATED void CommandImpl::ReplaceMobileByHMIAppId(
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& message) {
+ if (!ReplaceMobileWithHMIAppId(message)) {
+ LOG4CXX_ERROR(logger_, "Substitution mobile --> HMI id is failed.");
+ }
}
-void CommandImpl::ReplaceHMIByMobileAppId(
+bool CommandImpl::ReplaceHMIWithMobileAppId(
NsSmartDeviceLink::NsSmartObjects::SmartObject& message) {
if (message.keyExists(strings::app_id)) {
ApplicationSharedPtr application =
application_manager_.application_by_hmi_app(
message[strings::app_id].asUInt());
- if (application.valid()) {
- LOG4CXX_DEBUG(logger_,
- "ReplaceHMIByMobileAppId from "
- << message[strings::app_id].asInt() << " to "
- << application->app_id());
- message[strings::app_id] = application->app_id();
+ if (!application) {
+ LOG4CXX_ERROR(logger_, "Substitution HMI --> mobile id is failed.");
+ return false;
}
+ LOG4CXX_DEBUG(logger_,
+ "ReplaceHMIWithMobileAppId from "
+ << message[strings::app_id].asInt() << " to "
+ << application->app_id());
+ message[strings::app_id] = application->app_id();
} else {
switch (message.getType()) {
case smart_objects::SmartType::SmartType_Array: {
smart_objects::SmartArray* message_array = message.asArray();
smart_objects::SmartArray::iterator it = message_array->begin();
for (; it != message_array->end(); ++it) {
- ReplaceHMIByMobileAppId(*it);
+ if (!ReplaceHMIWithMobileAppId(*it)) {
+ break;
+ }
}
break;
}
@@ -158,13 +178,24 @@ void CommandImpl::ReplaceHMIByMobileAppId(
std::set<std::string> keys = message.enumerate();
std::set<std::string>::const_iterator key = keys.begin();
for (; key != keys.end(); ++key) {
- ReplaceHMIByMobileAppId(message[*key]);
+ if (!ReplaceHMIWithMobileAppId(message[*key])) {
+ break;
+ }
}
break;
}
default: { break; }
}
}
+
+ return true;
+}
+
+DEPRECATED void CommandImpl::ReplaceHMIByMobileAppId(
+ NsSmartDeviceLink::NsSmartObjects::SmartObject& message) {
+ if (!ReplaceHMIWithMobileAppId(message)) {
+ LOG4CXX_ERROR(logger_, "Substitution HMI --> mobile id is failed.");
+ }
}
} // namespace commands
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 09aa4169e5..515d8a998c 100644
--- a/src/components/application_manager/src/commands/command_request_impl.cc
+++ b/src/components/application_manager/src/commands/command_request_impl.cc
@@ -31,6 +31,7 @@
*/
#include <algorithm>
+#include <numeric>
#include <string>
#include "utils/macro.h"
#include "utils/make_shared.h"
diff --git a/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc b/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc
index 80b1edb5bb..c6c550a474 100644
--- a/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc
+++ b/src/components/application_manager/src/commands/hmi/basic_communication_on_awake_sdl.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Ford Motor Company
+ * Copyright (c) 2017, Ford Motor Company
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,3 +29,45 @@
* 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_on_awake_sdl.h"
+#include "application_manager/message_helper.h"
+#include "application_manager/resumption/resume_ctrl.h"
+
+namespace application_manager {
+
+namespace commands {
+
+OnAwakeSDLNotification::OnAwakeSDLNotification(
+ const MessageSharedPtr& message, ApplicationManager& application_manager)
+ : NotificationFromHMI(message, application_manager) {}
+
+OnAwakeSDLNotification::~OnAwakeSDLNotification() {}
+
+void OnAwakeSDLNotification::Run() {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if (!application_manager_.resume_controller().is_suspended()) {
+ return;
+ }
+
+ {
+ DataAccessor<ApplicationSet> accessor = application_manager_.applications();
+ ApplicationSetIt itBegin = accessor.GetData().begin();
+ ApplicationSetIt itEnd = accessor.GetData().end();
+ for (; itBegin != itEnd; ++itBegin) {
+ const ApplicationSharedPtr app = *itBegin;
+ if (app && app->IsHashChangedDuringSuspend()) {
+ MessageHelper::SendHashUpdateNotification(app->app_id(),
+ application_manager_);
+ app->SetHashChangedDuringSuspend(false);
+ }
+ }
+ }
+
+ application_manager_.resume_controller().OnAwake();
+}
+
+} // namespace commands
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc b/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc
index 64eb63fde8..3c2d73b10c 100644
--- a/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc
+++ b/src/components/application_manager/src/commands/hmi/notification_from_hmi.cc
@@ -42,7 +42,7 @@ NotificationFromHMI::NotificationFromHMI(
const MessageSharedPtr& message, ApplicationManager& application_manager)
: CommandImpl(message, application_manager) {
// Replace HMI app id with Mobile connection id
- ReplaceHMIByMobileAppId(*message);
+ ReplaceHMIWithMobileAppId(*message);
}
NotificationFromHMI::~NotificationFromHMI() {}
diff --git a/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc b/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc
index f1e933b7ef..d52df950c3 100644
--- a/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc
+++ b/src/components/application_manager/src/commands/hmi/notification_to_hmi.cc
@@ -39,15 +39,13 @@ namespace commands {
NotificationToHMI::NotificationToHMI(const MessageSharedPtr& message,
ApplicationManager& application_manager)
- : CommandImpl(message, application_manager) {
- // Replace Mobile connection id with HMI app id
- ReplaceMobileByHMIAppId(*(message.get()));
-}
+ : CommandImpl(message, application_manager) {}
NotificationToHMI::~NotificationToHMI() {}
bool NotificationToHMI::Init() {
- return true;
+ // Replace Mobile connection id with HMI app id
+ return ReplaceMobileWithHMIAppId(*message_);
}
bool NotificationToHMI::CleanUp() {
diff --git a/src/components/application_manager/src/commands/hmi/on_app_unregistered_notification.cc b/src/components/application_manager/src/commands/hmi/on_app_unregistered_notification.cc
index 10ea1ea303..f64e3e111b 100644
--- a/src/components/application_manager/src/commands/hmi/on_app_unregistered_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_app_unregistered_notification.cc
@@ -44,6 +44,12 @@ OnAppUnregisteredNotification::OnAppUnregisteredNotification(
OnAppUnregisteredNotification::~OnAppUnregisteredNotification() {}
+bool OnAppUnregisteredNotification::Init() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ LOG4CXX_DEBUG(logger_, "Replacement of hmi id is skipped.");
+ return true;
+}
+
void OnAppUnregisteredNotification::Run() {
LOG4CXX_AUTO_TRACE(logger_);
diff --git a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc
index 07a95adcea..cb68b21263 100644
--- a/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc
+++ b/src/components/application_manager/src/commands/hmi/on_exit_all_applications_notification.cc
@@ -75,6 +75,7 @@ void OnExitAllApplicationsNotification::Run() {
break;
}
case hmi_apis::Common_ApplicationsCloseReason::SUSPEND: {
+ application_manager_.resume_controller().OnSuspend();
SendOnSDLPersistenceComplete();
return;
}
diff --git a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc
index 1119e7c4fd..5a4e7b149e 100644
--- a/src/components/application_manager/src/commands/hmi/request_from_hmi.cc
+++ b/src/components/application_manager/src/commands/hmi/request_from_hmi.cc
@@ -43,7 +43,7 @@ RequestFromHMI::RequestFromHMI(const MessageSharedPtr& message,
: CommandImpl(message, application_manager)
, EventObserver(application_manager.event_dispatcher()) {
// Replace HMI app id with Mobile connection id
- ReplaceHMIByMobileAppId(*(message.get()));
+ ReplaceHMIWithMobileAppId(*message);
}
RequestFromHMI::~RequestFromHMI() {}
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 39d549ac72..6905e7cdef 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
@@ -61,15 +61,13 @@ bool ChangeInterfaceState(ApplicationManager& application_manager,
RequestToHMI::RequestToHMI(const MessageSharedPtr& message,
ApplicationManager& application_manager)
- : CommandImpl(message, application_manager) {
- // Replace Mobile connection id with HMI app id
- ReplaceMobileByHMIAppId(*(message.get()));
-}
+ : CommandImpl(message, application_manager) {}
RequestToHMI::~RequestToHMI() {}
bool RequestToHMI::Init() {
- return true;
+ // Replace Mobile connection id with HMI app id
+ return ReplaceMobileWithHMIAppId(*message_);
}
bool RequestToHMI::CleanUp() {
diff --git a/src/components/application_manager/src/commands/hmi/response_from_hmi.cc b/src/components/application_manager/src/commands/hmi/response_from_hmi.cc
index 23d8e6e229..d6d5d95d07 100644
--- a/src/components/application_manager/src/commands/hmi/response_from_hmi.cc
+++ b/src/components/application_manager/src/commands/hmi/response_from_hmi.cc
@@ -48,7 +48,7 @@ ResponseFromHMI::ResponseFromHMI(const MessageSharedPtr& message,
}
// Replace HMI app id with Mobile connection id
- ReplaceHMIByMobileAppId(*(message.get()));
+ ReplaceHMIWithMobileAppId(*message);
}
ResponseFromHMI::~ResponseFromHMI() {}
diff --git a/src/components/application_manager/src/commands/hmi/response_to_hmi.cc b/src/components/application_manager/src/commands/hmi/response_to_hmi.cc
index e6f64047ba..de1e1e0fde 100644
--- a/src/components/application_manager/src/commands/hmi/response_to_hmi.cc
+++ b/src/components/application_manager/src/commands/hmi/response_to_hmi.cc
@@ -39,15 +39,13 @@ namespace commands {
ResponseToHMI::ResponseToHMI(const MessageSharedPtr& message,
ApplicationManager& application_manager)
- : CommandImpl(message, application_manager) {
- // Replace Mobile connection id with HMI app id
- ReplaceMobileByHMIAppId(*(message.get()));
-}
+ : CommandImpl(message, application_manager) {}
ResponseToHMI::~ResponseToHMI() {}
bool ResponseToHMI::Init() {
- return true;
+ // Replace Mobile connection id with HMI app id
+ return ReplaceMobileWithHMIAppId(*message_);
}
bool ResponseToHMI::CleanUp() {
diff --git a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc
index 84c6e0ba7c..f81d0a8c2a 100644
--- a/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc
+++ b/src/components/application_manager/src/commands/mobile/get_vehicle_data_request.cc
@@ -57,7 +57,7 @@ void GetVehicleDataRequest::Run() {
int32_t app_id =
(*message_)[strings::params][strings::connection_key].asUInt();
- ApplicationSharedPtr app = appplication_manager.application(app_id);
+ ApplicationSharedPtr app = application_manager_.application(app_id);
if (!app) {
LOG4CXX_ERROR(logger_, "NULL pointer");
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 cff16e577c..a05d41c098 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
@@ -224,7 +224,6 @@ PerformAudioPassThruRequest::PrepareResponseParameters() {
return response_params_;
}
-// DEPRECATED
bool PerformAudioPassThruRequest::PrepareResponseParameters(
mobile_apis::Result::eType& result_code, std::string& info) {
LOG4CXX_AUTO_TRACE(logger_);
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 1a60537874..a3a30ddb20 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
@@ -46,6 +46,7 @@
#include "application_manager/message_helper.h"
#include "application_manager/resumption/resume_ctrl.h"
#include "application_manager/policies/policy_handler.h"
+#include "application_manager/helpers/application_helper.h"
#include "config_profile/profile.h"
#include "interfaces/MOBILE_API.h"
#include "interfaces/generated_msg_version.h"
@@ -217,6 +218,13 @@ void RegisterAppInterfaceRequest::Run() {
return;
}
+ if (IsApplicationSwitched()) {
+ return;
+ }
+
+ const std::string mobile_app_id =
+ (*message_)[strings::msg_params][strings::app_id].asString();
+
ApplicationSharedPtr application =
application_manager_.application(connection_key());
@@ -362,7 +370,7 @@ void RegisterAppInterfaceRequest::Run() {
GetPolicyHandler().SetDeviceInfo(device_mac, device_info);
- SendRegisterAppInterfaceResponseToMobile();
+ SendRegisterAppInterfaceResponseToMobile(ApplicationType::kNewApplication);
smart_objects::SmartObjectSPtr so =
GetLockScreenIconUrlNotification(connection_key(), application);
application_manager_.ManageMobileCommand(so, commands::Command::ORIGIN_SDL);
@@ -501,7 +509,8 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params,
hmi_capabilities.rc_supported();
}
-void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
+void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
+ ApplicationType app_type) {
LOG4CXX_AUTO_TRACE(logger_);
smart_objects::SmartObject response_params(smart_objects::SmartType_Map);
@@ -572,18 +581,27 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
FillUIRelatedFields(response_params, hmi_capabilities);
}
+ if (HmiInterfaces::STATE_NOT_AVAILABLE !=
+ application_manager_.hmi_interfaces().GetInterfaceState(
+ HmiInterfaces::HMI_INTERFACE_VehicleInfo)) {
+ FillVIRelatedFields(response_params, hmi_capabilities);
+ }
+
if (hmi_capabilities.button_capabilities()) {
response_params[hmi_response::button_capabilities] =
*hmi_capabilities.button_capabilities();
}
+
if (hmi_capabilities.soft_button_capabilities()) {
response_params[hmi_response::soft_button_capabilities] =
*hmi_capabilities.soft_button_capabilities();
}
+
if (hmi_capabilities.preset_bank_capabilities()) {
response_params[hmi_response::preset_bank_capabilities] =
*hmi_capabilities.preset_bank_capabilities();
}
+
if (hmi_capabilities.hmi_zone_capabilities()) {
if (smart_objects::SmartType_Array ==
hmi_capabilities.hmi_zone_capabilities()->getType()) {
@@ -596,23 +614,11 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
}
}
- if (HmiInterfaces::STATE_NOT_AVAILABLE !=
- application_manager_.hmi_interfaces().GetInterfaceState(
- HmiInterfaces::HMI_INTERFACE_TTS)) {
- FillTTSRelatedFields(response_params, hmi_capabilities);
- }
-
if (hmi_capabilities.pcm_stream_capabilities()) {
response_params[strings::pcm_stream_capabilities] =
*hmi_capabilities.pcm_stream_capabilities();
}
- if (HmiInterfaces::STATE_NOT_AVAILABLE !=
- application_manager_.hmi_interfaces().GetInterfaceState(
- HmiInterfaces::HMI_INTERFACE_VehicleInfo)) {
- FillVIRelatedFields(response_params, hmi_capabilities);
- }
-
const std::vector<uint32_t>& diag_modes =
application_manager_.get_settings().supported_diag_modes();
if (!diag_modes.empty()) {
@@ -623,6 +629,7 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
++index;
}
}
+
response_params[strings::sdl_version] =
application_manager_.get_settings().sdl_version();
const std::string ccpu_version =
@@ -631,6 +638,27 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
response_params[strings::system_software_version] = ccpu_version;
}
+ if (ApplicationType::kSwitchedApplicationWrongHashId == app_type) {
+ LOG4CXX_DEBUG(logger_,
+ "Application has been switched from another transport, "
+ "but doesn't have correct hashID.");
+
+ application_manager::DeleteApplicationData(application,
+ application_manager_);
+
+ SendResponse(
+ true, mobile_apis::Result::RESUME_FAILED, NULL, &response_params);
+ return;
+ }
+
+ if (ApplicationType::kSwitchedApplicationHashOk == app_type) {
+ LOG4CXX_DEBUG(logger_,
+ "Application has been switched from another transport "
+ "and has correct hashID.");
+ SendResponse(true, mobile_apis::Result::SUCCESS, NULL, &response_params);
+ return;
+ }
+
bool resumption =
(*message_)[strings::msg_params].keyExists(strings::hash_id);
@@ -713,6 +741,11 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
SendChangeRegistrationOnHMI(application);
}
+DEPRECATED void
+RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile() {
+ SendRegisterAppInterfaceResponseToMobile(ApplicationType::kNewApplication);
+}
+
void RegisterAppInterfaceRequest::SendChangeRegistration(
const hmi_apis::FunctionID::eType function_id,
const int32_t language,
@@ -1194,6 +1227,56 @@ void RegisterAppInterfaceRequest::SendSubscribeCustomButtonNotification() {
CreateHMINotification(FunctionID::Buttons_OnButtonSubscription, msg_params);
}
+bool RegisterAppInterfaceRequest::IsApplicationSwitched() {
+ const smart_objects::SmartObject& msg_params =
+ (*message_)[strings::msg_params];
+
+ const std::string& policy_app_id = msg_params[strings::app_id].asString();
+
+ LOG4CXX_DEBUG(logger_, "Looking for application id " << policy_app_id);
+
+ auto app = application_manager_.application_by_policy_id(policy_app_id);
+
+ if (!app) {
+ LOG4CXX_DEBUG(logger_,
+ "Application with policy id " << policy_app_id
+ << " is not found.");
+ return false;
+ }
+
+ LOG4CXX_DEBUG(logger_,
+ "Application with policy id " << policy_app_id << " is found.");
+ if (!application_manager_.IsAppInReconnectMode(policy_app_id)) {
+ LOG4CXX_DEBUG(logger_,
+ "Policy id " << policy_app_id
+ << " is not found in reconnection list.");
+ SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY);
+ return false;
+ }
+
+ LOG4CXX_DEBUG(logger_, "Application is found in reconnection list.");
+
+ auto app_type = ApplicationType::kSwitchedApplicationWrongHashId;
+ if ((*message_)[strings::msg_params].keyExists(strings::hash_id)) {
+ const auto hash_id =
+ (*message_)[strings::msg_params][strings::hash_id].asString();
+
+ auto& resume_ctrl = application_manager_.resume_controller();
+ if (resume_ctrl.CheckApplicationHash(app, hash_id)) {
+ app_type = ApplicationType::kSwitchedApplicationHashOk;
+ }
+ }
+
+ application_manager_.ProcessReconnection(app, connection_key());
+ SendRegisterAppInterfaceResponseToMobile(app_type);
+
+ application_manager_.SendHMIStatusNotification(app);
+
+ application_manager_.OnApplicationSwitched(app);
+
+ return true;
+}
+
policy::PolicyHandlerInterface&
RegisterAppInterfaceRequest::GetPolicyHandler() {
return application_manager_.GetPolicyHandler();
diff --git a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc
index 965741edf7..8195697dfc 100644
--- a/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc
+++ b/src/components/application_manager/src/commands/mobile/subscribe_way_points_request.cc
@@ -25,13 +25,13 @@ void SubscribeWayPointsRequest::Run() {
return;
}
- if (application_manager_.IsAppSubscribedForWayPoints(app->app_id())) {
+ if (application_manager_.IsAppSubscribedForWayPoints(app)) {
SendResponse(false, mobile_apis::Result::IGNORED);
return;
}
if (application_manager_.IsAnyAppSubscribedForWayPoints()) {
- application_manager_.SubscribeAppForWayPoints(app->app_id());
+ application_manager_.SubscribeAppForWayPoints(app);
SendResponse(true, mobile_apis::Result::SUCCESS);
return;
}
@@ -57,7 +57,7 @@ void SubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
const bool result = PrepareResultForMobileResponse(
result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
if (result) {
- application_manager_.SubscribeAppForWayPoints(app->app_id());
+ application_manager_.SubscribeAppForWayPoints(app);
}
SendResponse(result,
MessageHelper::HMIToMobileResult(result_code),
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
index f7317d72f9..d6ad928bf7 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_vehicle_data_request.cc
@@ -253,6 +253,14 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
}
EndAwaitForInterface(HmiInterfaces::HMI_INTERFACE_VehicleInfo);
+ ApplicationSharedPtr app =
+ application_manager_.application(CommandRequestImpl::connection_key());
+
+ if (!app) {
+ LOG4CXX_ERROR(logger_, "NULL pointer.");
+ return;
+ }
+
#ifdef HMI_DBUS_API
for (HmiRequests::iterator it = hmi_requests_.begin();
it != hmi_requests_.end();
@@ -308,7 +316,7 @@ void UnsubscribeVehicleDataRequest::on_event(const event_engine::Event& event) {
}
SendResponse(any_arg_success, status, NULL, &response_params);
if (true == any_arg_success) {
- UpdateHash();
+ app->UpdateHash();
}
}
#else
diff --git a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc
index 88ed396250..dc3404c022 100644
--- a/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc
+++ b/src/components/application_manager/src/commands/mobile/unsubscribe_way_points_request.cc
@@ -25,7 +25,7 @@ void UnSubscribeWayPointsRequest::Run() {
return;
}
- if (!application_manager_.IsAppSubscribedForWayPoints(app->app_id())) {
+ if (!application_manager_.IsAppSubscribedForWayPoints(app)) {
SendResponse(false, mobile_apis::Result::IGNORED);
return;
}
@@ -51,7 +51,7 @@ void UnSubscribeWayPointsRequest::on_event(const event_engine::Event& event) {
const bool result = PrepareResultForMobileResponse(
result_code, HmiInterfaces::HMI_INTERFACE_Navigation);
if (result) {
- application_manager_.UnsubscribeAppFromWayPoints(app->app_id());
+ application_manager_.UnsubscribeAppFromWayPoints(app);
}
SendResponse(result,
MessageHelper::HMIToMobileResult(result_code),
diff --git a/src/components/application_manager/src/helpers/application_helper.cc b/src/components/application_manager/src/helpers/application_helper.cc
new file mode 100644
index 0000000000..16b49faa2a
--- /dev/null
+++ b/src/components/application_manager/src/helpers/application_helper.cc
@@ -0,0 +1,146 @@
+#include <vector>
+#include <string>
+#include "application_manager/helpers/application_helper.h"
+#include "application_manager/message_helper.h"
+#include "utils/logger.h"
+#include "utils/file_system.h"
+
+namespace {
+using namespace application_manager;
+void DeleteWayPoints(ApplicationSharedPtr app,
+ ApplicationManager& app_manager) {
+ app_manager.UnsubscribeAppFromWayPoints(app);
+ if (!app_manager.IsAnyAppSubscribedForWayPoints()) {
+ MessageHelper::SendUnsubscribedWayPoints(app_manager);
+ }
+}
+
+void DeleteCommands(ApplicationSharedPtr app, ApplicationManager& app_manager) {
+ CommandsMap cmap = app->commands_map().GetData();
+
+ for (auto cmd : cmap) {
+ MessageHelper::SendDeleteCommandRequest(cmd.second, app, app_manager);
+ app->RemoveCommand(cmd.first);
+ }
+}
+
+void DeleteSubmenus(ApplicationSharedPtr app, ApplicationManager& app_manager) {
+ SubMenuMap smap = app->sub_menu_map().GetData();
+
+ for (auto smenu : smap) {
+ MessageHelper::SendDeleteSubmenuRequest(smenu.second, app, app_manager);
+ app->RemoveSubMenu(smenu.first);
+ }
+}
+
+void DeleteChoiceSets(ApplicationSharedPtr app,
+ ApplicationManager& app_manager) {
+ ChoiceSetMap csmap = app->choice_set_map().GetData();
+
+ for (auto choice : csmap) {
+ MessageHelper::SendDeleteChoiceSetRequest(choice.second, app, app_manager);
+ app->RemoveChoiceSet(choice.first);
+ }
+}
+
+void DeleteGlobalProperties(ApplicationSharedPtr app,
+ ApplicationManager& app_manager) {
+ using namespace smart_objects;
+
+ const std::vector<std::string>& timeout_prompt =
+ app_manager.get_settings().time_out_promt();
+
+ SmartObject so_default_timeout_prompt = SmartObject(SmartType_Array);
+
+ int32_t index = 0;
+ for (auto prompt : timeout_prompt) {
+ SmartObject timeoutPrompt = SmartObject(SmartType_Map);
+ timeoutPrompt[strings::text] = timeout_prompt[static_cast<size_t>(index)];
+ timeoutPrompt[strings::type] = hmi_apis::Common_SpeechCapabilities::SC_TEXT;
+ so_default_timeout_prompt[index] = timeoutPrompt;
+ ++index;
+ }
+
+ app->set_timeout_prompt(so_default_timeout_prompt);
+
+ SmartObject empty_so = SmartObject(SmartType_Array);
+ app->set_help_prompt(empty_so);
+ app->reset_vr_help_title();
+ app->reset_vr_help();
+ app->set_keyboard_props(empty_so);
+ app->set_menu_icon(empty_so);
+ app->set_menu_title(empty_so);
+
+ MessageHelper::SendResetPropertiesRequest(app, app_manager);
+}
+
+void DeleteButtonSubscriptions(ApplicationSharedPtr app,
+ ApplicationManager& app_manager) {
+ ButtonSubscriptions buttons = app->SubscribedButtons().GetData();
+
+ for (auto button : buttons) {
+ if (mobile_apis::ButtonName::CUSTOM_BUTTON == button) {
+ continue;
+ }
+ MessageHelper::SendUnsubscribeButtonNotification(button, app, app_manager);
+ app->UnsubscribeFromButton(button);
+ }
+}
+
+void DeleteVISubscriptions(ApplicationSharedPtr app,
+ ApplicationManager& app_manager) {
+ VehicleInfoSubscriptions ivi = app->SubscribedIVI().GetData();
+
+ for (auto i : ivi) {
+ app->UnsubscribeFromIVI(i);
+ SubscribedToIVIPredicate p(i);
+ auto app = FindApp(app_manager.applications(), p);
+ if (!app) {
+ MessageHelper::SendUnsubscribeIVIRequest(i, app, app_manager);
+ }
+ }
+}
+
+void CleanupAppFiles(ApplicationSharedPtr app) {
+ const auto icon_file = app->app_icon_path();
+
+ auto files = app->getAppFiles();
+ for (auto file : files) {
+ auto file_name = file.first;
+ if (icon_file == file_name) {
+ continue;
+ }
+ app->DeleteFile(file_name);
+ file_system::DeleteFile(file_name);
+ }
+}
+} // namespace
+
+namespace application_manager {
+
+CREATE_LOGGERPTR_GLOBAL(logger, "ApplicationManager")
+
+SubscribedToIVIPredicate::SubscribedToIVIPredicate(uint32_t vehicle_info)
+ : vehicle_info_(vehicle_info) {}
+
+bool SubscribedToIVIPredicate::operator()(
+ const ApplicationSharedPtr app) const {
+ return app ? app->IsSubscribedToIVI(vehicle_info_) : false;
+}
+
+void DeleteApplicationData(ApplicationSharedPtr app,
+ ApplicationManager& app_manager) {
+ LOG4CXX_AUTO_TRACE(logger);
+ DCHECK_OR_RETURN_VOID(app);
+
+ DeleteWayPoints(app, app_manager);
+ DeleteCommands(app, app_manager);
+ DeleteSubmenus(app, app_manager);
+ DeleteChoiceSets(app, app_manager);
+ DeleteGlobalProperties(app, app_manager);
+ DeleteButtonSubscriptions(app, app_manager);
+ DeleteVISubscriptions(app, app_manager);
+ CleanupAppFiles(app);
+}
+
+} // namespace application_manager
diff --git a/src/components/application_manager/src/hmi_command_factory.cc b/src/components/application_manager/src/hmi_command_factory.cc
index ffaa8d9b5f..a7f3ce7e6b 100644
--- a/src/components/application_manager/src/hmi_command_factory.cc
+++ b/src/components/application_manager/src/hmi_command_factory.cc
@@ -269,6 +269,7 @@
#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_on_awake_sdl.h"
#include "application_manager/commands/hmi/sdl_policy_update.h"
#include "application_manager/commands/hmi/sdl_policy_update_response.h"
#include "application_manager/commands/hmi/on_received_policy_update.h"
@@ -781,6 +782,11 @@ CommandSharedPtr HMICommandFactory::CreateCommand(
message, application_manager));
break;
}
+ case hmi_apis::FunctionID::BasicCommunication_OnAwakeSDL: {
+ command.reset(
+ new commands::OnAwakeSDLNotification(message, application_manager));
+ break;
+ }
case hmi_apis::FunctionID::BasicCommunication_OnExitApplication: {
command.reset(new commands::OnExitApplicationNotification(
message, application_manager));
diff --git a/src/components/application_manager/src/hmi_state.cc b/src/components/application_manager/src/hmi_state.cc
index 393a9d7784..bc1ccd8f42 100644
--- a/src/components/application_manager/src/hmi_state.cc
+++ b/src/components/application_manager/src/hmi_state.cc
@@ -37,47 +37,65 @@
namespace application_manager {
-HmiState::HmiState(uint32_t app_id,
+HmiState::HmiState(utils::SharedPtr<Application> app,
const ApplicationManager& app_mngr,
StateID state_id)
- : app_id_(app_id)
+ : app_(app)
, state_id_(state_id)
, app_mngr_(app_mngr)
, hmi_level_(mobile_apis::HMILevel::INVALID_ENUM)
, audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM)
, system_context_(mobile_apis::SystemContext::INVALID_ENUM) {}
-HmiState::HmiState(uint32_t app_id, const ApplicationManager& app_mngr)
- : app_id_(app_id)
+HmiState::HmiState(utils::SharedPtr<Application> app,
+ const ApplicationManager& app_mngr)
+ : app_(app)
, state_id_(STATE_ID_REGULAR)
, app_mngr_(app_mngr)
, hmi_level_(mobile_apis::HMILevel::INVALID_ENUM)
, audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM)
, system_context_(mobile_apis::SystemContext::INVALID_ENUM) {}
+DEPRECATED HmiState::HmiState(uint32_t app_id,
+ const ApplicationManager& app_mngr,
+ StateID state_id)
+ : state_id_(state_id)
+ , app_mngr_(app_mngr)
+ , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM)
+ , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM)
+ , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {
+ app_ = app_mngr_.application(app_id);
+}
+
+DEPRECATED HmiState::HmiState(uint32_t app_id,
+ const ApplicationManager& app_mngr)
+ : state_id_(STATE_ID_REGULAR)
+ , app_mngr_(app_mngr)
+ , hmi_level_(mobile_apis::HMILevel::INVALID_ENUM)
+ , audio_streaming_state_(mobile_apis::AudioStreamingState::INVALID_ENUM)
+ , system_context_(mobile_apis::SystemContext::INVALID_ENUM) {
+ app_ = app_mngr_.application(app_id);
+}
+
void HmiState::set_parent(HmiStatePtr parent) {
DCHECK_OR_RETURN_VOID(parent);
parent_ = parent;
}
-bool HmiState::is_navi_app(const uint32_t app_id) const {
- const ApplicationSharedPtr app = app_mngr_.application(app_id);
- return app ? app->is_navi() : false;
+bool HmiState::is_navi_app() const {
+ return app_->is_navi();
}
-bool HmiState::is_media_app(const uint32_t app_id) const {
- const ApplicationSharedPtr app = app_mngr_.application(app_id);
- return app ? app->is_media_application() : false;
+bool HmiState::is_media_app() const {
+ return app_->is_media_application();
}
-bool HmiState::is_voice_communication_app(const uint32_t app_id) const {
- const ApplicationSharedPtr app = app_mngr_.application(app_id);
- return app ? app->is_voice_communication_supported() : false;
+bool HmiState::is_voice_communication_app() const {
+ return app_->is_voice_communication_supported();
}
-bool HmiState::is_mobile_projection_app(const uint32_t app_id) const {
- const ApplicationSharedPtr app = app_mngr_.application(app_id);
- return app ? app->mobile_projection_enabled() : false;
+bool HmiState::is_mobile_projection_app() const {
+ return app_->mobile_projection_enabled();
}
mobile_apis::AudioStreamingState::eType VRHmiState::audio_streaming_state()
@@ -86,10 +104,20 @@ mobile_apis::AudioStreamingState::eType VRHmiState::audio_streaming_state()
return AudioStreamingState::NOT_AUDIBLE;
}
-VRHmiState::VRHmiState(uint32_t app_id, const ApplicationManager& app_mngr)
+VRHmiState::VRHmiState(utils::SharedPtr<Application> app,
+ const ApplicationManager& app_mngr)
+ : HmiState(app, app_mngr, STATE_ID_VR_SESSION) {}
+
+DEPRECATED VRHmiState::VRHmiState(uint32_t app_id,
+ const ApplicationManager& app_mngr)
: HmiState(app_id, app_mngr, STATE_ID_VR_SESSION) {}
-TTSHmiState::TTSHmiState(uint32_t app_id, const ApplicationManager& app_mngr)
+TTSHmiState::TTSHmiState(utils::SharedPtr<Application> app,
+ const ApplicationManager& app_mngr)
+ : HmiState(app, app_mngr, STATE_ID_TTS_SESSION) {}
+
+DEPRECATED TTSHmiState::TTSHmiState(uint32_t app_id,
+ const ApplicationManager& app_mngr)
: HmiState(app_id, app_mngr, STATE_ID_TTS_SESSION) {}
mobile_apis::AudioStreamingState::eType TTSHmiState::audio_streaming_state()
@@ -107,8 +135,12 @@ mobile_apis::AudioStreamingState::eType TTSHmiState::audio_streaming_state()
return expected_state;
}
-NaviStreamingHmiState::NaviStreamingHmiState(uint32_t app_id,
+NaviStreamingHmiState::NaviStreamingHmiState(utils::SharedPtr<Application> app,
const ApplicationManager& app_mngr)
+ : HmiState(app, app_mngr, STATE_ID_NAVI_STREAMING) {}
+
+DEPRECATED NaviStreamingHmiState::NaviStreamingHmiState(
+ uint32_t app_id, const ApplicationManager& app_mngr)
: HmiState(app_id, app_mngr, STATE_ID_NAVI_STREAMING) {}
mobile_apis::AudioStreamingState::eType
@@ -117,7 +149,7 @@ NaviStreamingHmiState::audio_streaming_state() const {
using namespace mobile_apis;
AudioStreamingState::eType expected_state = parent()->audio_streaming_state();
- if (!is_navi_app(app_id_) && AudioStreamingState::AUDIBLE == expected_state) {
+ if (!is_navi_app() && AudioStreamingState::AUDIBLE == expected_state) {
if (app_mngr_.is_attenuated_supported()) {
expected_state = AudioStreamingState::ATTENUATED;
} else {
@@ -127,8 +159,12 @@ NaviStreamingHmiState::audio_streaming_state() const {
return expected_state;
}
-PhoneCallHmiState::PhoneCallHmiState(uint32_t app_id,
+PhoneCallHmiState::PhoneCallHmiState(utils::SharedPtr<Application> app,
const ApplicationManager& app_mngr)
+ : HmiState(app, app_mngr, STATE_ID_PHONE_CALL) {}
+
+DEPRECATED PhoneCallHmiState::PhoneCallHmiState(
+ uint32_t app_id, const ApplicationManager& app_mngr)
: HmiState(app_id, app_mngr, STATE_ID_PHONE_CALL) {}
mobile_apis::HMILevel::eType PhoneCallHmiState::hmi_level() const {
@@ -139,21 +175,29 @@ mobile_apis::HMILevel::eType PhoneCallHmiState::hmi_level() const {
HMILevel::HMI_NONE)) {
return parent()->hmi_level();
}
- if (is_navi_app(app_id_) || is_mobile_projection_app(app_id_)) {
+ if (is_navi_app() || is_mobile_projection_app()) {
return HMILevel::HMI_LIMITED;
}
- if (!is_media_app(app_id_)) {
+ if (!is_media_app()) {
return parent()->hmi_level();
}
return HMILevel::HMI_BACKGROUND;
}
-SafetyModeHmiState::SafetyModeHmiState(uint32_t app_id,
+SafetyModeHmiState::SafetyModeHmiState(utils::SharedPtr<Application> app,
const ApplicationManager& app_mngr)
+ : HmiState(app, app_mngr, STATE_ID_SAFETY_MODE) {}
+
+DEPRECATED SafetyModeHmiState::SafetyModeHmiState(
+ uint32_t app_id, const ApplicationManager& app_mngr)
: HmiState(app_id, app_mngr, STATE_ID_SAFETY_MODE) {}
-DeactivateHMI::DeactivateHMI(uint32_t app_id,
+DeactivateHMI::DeactivateHMI(utils::SharedPtr<Application> app,
const ApplicationManager& app_mngr)
+ : HmiState(app, app_mngr, STATE_ID_DEACTIVATE_HMI) {}
+
+DEPRECATED DeactivateHMI::DeactivateHMI(uint32_t app_id,
+ const ApplicationManager& app_mngr)
: HmiState(app_id, app_mngr, STATE_ID_DEACTIVATE_HMI) {}
mobile_apis::HMILevel::eType DeactivateHMI::hmi_level() const {
@@ -167,7 +211,12 @@ mobile_apis::HMILevel::eType DeactivateHMI::hmi_level() const {
return HMILevel::HMI_BACKGROUND;
}
-AudioSource::AudioSource(uint32_t app_id, const ApplicationManager& app_mngr)
+AudioSource::AudioSource(utils::SharedPtr<Application> app,
+ const ApplicationManager& app_mngr)
+ : HmiState(app, app_mngr, STATE_ID_AUDIO_SOURCE) {}
+
+DEPRECATED AudioSource::AudioSource(uint32_t app_id,
+ const ApplicationManager& app_mngr)
: HmiState(app_id, app_mngr, STATE_ID_AUDIO_SOURCE) {}
mobile_apis::HMILevel::eType AudioSource::hmi_level() const {
@@ -181,13 +230,18 @@ mobile_apis::HMILevel::eType AudioSource::hmi_level() const {
HMILevel::HMI_NONE)) {
return parent()->hmi_level();
}
- if (is_navi_app(app_id_) || is_voice_communication_app(app_id_)) {
+ if (is_navi_app() || is_voice_communication_app()) {
return HMILevel::HMI_LIMITED;
}
return HMILevel::HMI_BACKGROUND;
}
-EmbeddedNavi::EmbeddedNavi(uint32_t app_id, const ApplicationManager& app_mngr)
+EmbeddedNavi::EmbeddedNavi(utils::SharedPtr<Application> app,
+ const ApplicationManager& app_mngr)
+ : HmiState(app, app_mngr, STATE_ID_EMBEDDED_NAVI) {}
+
+DEPRECATED EmbeddedNavi::EmbeddedNavi(uint32_t app_id,
+ const ApplicationManager& app_mngr)
: HmiState(app_id, app_mngr, STATE_ID_EMBEDDED_NAVI) {}
mobile_apis::HMILevel::eType EmbeddedNavi::hmi_level() const {
@@ -198,7 +252,7 @@ mobile_apis::HMILevel::eType EmbeddedNavi::hmi_level() const {
HMILevel::HMI_NONE)) {
return parent()->hmi_level();
}
- if (is_media_app(app_id_)) {
+ if (is_media_app()) {
return HMILevel::HMI_LIMITED;
}
return HMILevel::HMI_BACKGROUND;
diff --git a/src/components/application_manager/src/message.cc b/src/components/application_manager/src/message.cc
index d67a235a76..7bc686aef1 100644
--- a/src/components/application_manager/src/message.cc
+++ b/src/components/application_manager/src/message.cc
@@ -89,7 +89,7 @@ Message& Message::operator=(const Message& message) {
set_data_size(message.data_size_);
set_payload_size(message.payload_size_);
if (message.binary_data_) {
- set_binary_data(message.binary_data_);
+ set_binary_data(static_cast<const BinaryData*>(message.binary_data_));
}
set_json_message(message.json_message_);
set_protocol_version(message.protocol_version());
@@ -194,7 +194,6 @@ void Message::set_message_type(MessageType type) {
type_ = type;
}
-// DEPRECATED
void Message::set_binary_data(BinaryData* data) {
if (NULL == data) {
NOTREACHED();
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 cf64152315..f544b5161e 100644
--- a/src/components/application_manager/src/message_helper/message_helper.cc
+++ b/src/components/application_manager/src/message_helper/message_helper.cc
@@ -42,6 +42,7 @@
#include <algorithm>
#include <utility>
#include <map>
+#include <functional>
#include "application_manager/application.h"
#include "application_manager/application_manager.h"
@@ -310,21 +311,20 @@ std::string MessageHelper::CommonLanguageToString(
return std::string();
}
-smart_objects::SmartObjectSPtr MessageHelper::CreateRequestObject(
- const uint32_t correlation_id) {
+smart_objects::SmartObjectSPtr MessageHelper::CreateMessageForHMI(
+ hmi_apis::messageType::eType message_type, const uint32_t correlation_id) {
using namespace smart_objects;
- SmartObjectSPtr request = utils::MakeShared<SmartObject>(SmartType_Map);
- SmartObject& ref = *request;
+ SmartObjectSPtr message = utils::MakeShared<SmartObject>(SmartType_Map);
+ SmartObject& ref = *message;
- ref[strings::params][strings::message_type] =
- static_cast<int>(hmi_apis::messageType::request);
+ ref[strings::params][strings::message_type] = static_cast<int>(message_type);
ref[strings::params][strings::protocol_version] =
commands::CommandImpl::protocol_version_;
ref[strings::params][strings::protocol_type] =
commands::CommandImpl::hmi_protocol_type_;
ref[strings::params][strings::correlation_id] = correlation_id;
- return request;
+ return message;
}
smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification(
@@ -344,8 +344,8 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateHashUpdateNotification(
void MessageHelper::SendDecryptCertificateToHMI(const std::string& file_name,
ApplicationManager& app_mngr) {
using namespace smart_objects;
- SmartObjectSPtr message =
- CreateRequestObject(app_mngr.GetNextHMICorrelationID());
+ SmartObjectSPtr message = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
DCHECK(message);
SmartObject& object = *message;
@@ -400,6 +400,253 @@ MessageHelper::GetOnAppInterfaceUnregisteredNotificationToMobile(
return notification;
}
+void MessageHelper::SendDeleteCommandRequest(smart_objects::SmartObject* cmd,
+ ApplicationSharedPtr application,
+ ApplicationManager& app_mngr) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN_VOID(cmd);
+ using namespace smart_objects;
+ SmartObject msg_params = SmartObject(smart_objects::SmartType_Map);
+
+ msg_params[strings::cmd_id] = (*cmd)[strings::cmd_id];
+ msg_params[strings::app_id] = application->app_id();
+
+ if ((*cmd).keyExists(strings::menu_params)) {
+ SmartObjectSPtr message = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
+ DCHECK(message);
+
+ SmartObject& object = *message;
+ object[strings::params][strings::function_id] =
+ hmi_apis::FunctionID::UI_DeleteCommand;
+
+ object[strings::msg_params] = msg_params;
+
+ app_mngr.ManageHMICommand(message);
+ }
+
+ if ((*cmd).keyExists(strings::vr_commands)) {
+ msg_params[strings::grammar_id] = application->get_grammar_id();
+ msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command;
+
+ SmartObjectSPtr message = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
+ DCHECK(message);
+
+ SmartObject& object = *message;
+ object[strings::params][strings::function_id] =
+ hmi_apis::FunctionID::VR_DeleteCommand;
+
+ object[strings::msg_params] = msg_params;
+
+ app_mngr.ManageHMICommand(message);
+ }
+}
+
+void MessageHelper::SendDeleteSubmenuRequest(smart_objects::SmartObject* cmd,
+ ApplicationSharedPtr application,
+ ApplicationManager& app_mngr) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN_VOID(cmd);
+ using namespace smart_objects;
+
+ SmartObject msg_params = SmartObject(smart_objects::SmartType_Map);
+
+ msg_params[strings::menu_id] = (*cmd)[strings::menu_id];
+ msg_params[strings::app_id] = application->app_id();
+
+ SmartObjectSPtr message = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
+ DCHECK(message);
+
+ SmartObject& object = *message;
+ object[strings::params][strings::function_id] =
+ hmi_apis::FunctionID::UI_DeleteSubMenu;
+
+ object[strings::msg_params] = msg_params;
+
+ app_mngr.ManageHMICommand(message);
+
+ const DataAccessor<CommandsMap> accessor = application->commands_map();
+ const CommandsMap& commands = accessor.GetData();
+ CommandsMap::const_iterator it = commands.begin();
+
+ for (; commands.end() != it; ++it) {
+ if (!(*it->second).keyExists(strings::vr_commands)) {
+ continue;
+ }
+
+ if ((*cmd)[strings::menu_id].asInt() ==
+ (*it->second)[strings::menu_params][hmi_request::parent_id].asInt()) {
+ SmartObject msg_params = SmartObject(smart_objects::SmartType_Map);
+ msg_params[strings::cmd_id] = (*it->second)[strings::cmd_id].asInt();
+ msg_params[strings::app_id] = application->app_id();
+ msg_params[strings::grammar_id] = application->get_grammar_id();
+ msg_params[strings::type] = hmi_apis::Common_VRCommandType::Command;
+
+ SmartObjectSPtr message = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
+ DCHECK(message);
+
+ SmartObject& object = *message;
+ object[strings::params][strings::function_id] =
+ hmi_apis::FunctionID::VR_DeleteCommand;
+
+ object[strings::msg_params] = msg_params;
+
+ app_mngr.ManageHMICommand(message);
+ }
+ }
+}
+
+void MessageHelper::SendDeleteChoiceSetRequest(smart_objects::SmartObject* cmd,
+ ApplicationSharedPtr application,
+ ApplicationManager& app_mngr) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ DCHECK_OR_RETURN_VOID(cmd);
+ using namespace smart_objects;
+
+ // Same is deleted with SendDeleteCommandRequest?
+
+ SmartObject msg_params = SmartObject(smart_objects::SmartType_Map);
+
+ msg_params[strings::app_id] = application->app_id();
+ msg_params[strings::type] = hmi_apis::Common_VRCommandType::Choice;
+ msg_params[strings::grammar_id] = (*cmd)[strings::grammar_id];
+ cmd = &((*cmd)[strings::choice_set]);
+ for (uint32_t i = 0; i < (*cmd).length(); ++i) {
+ msg_params[strings::cmd_id] = (*cmd)[i][strings::choice_id];
+
+ SmartObjectSPtr message = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
+ DCHECK(message);
+
+ SmartObject& object = *message;
+ object[strings::params][strings::function_id] =
+ hmi_apis::FunctionID::VR_DeleteCommand;
+
+ object[strings::msg_params] = msg_params;
+
+ app_mngr.ManageHMICommand(message);
+ }
+}
+
+void MessageHelper::SendResetPropertiesRequest(ApplicationSharedPtr application,
+ ApplicationManager& app_mngr) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ using namespace smart_objects;
+
+ {
+ SmartObject msg_params = SmartObject(smart_objects::SmartType_Map);
+
+ msg_params = *MessageHelper::CreateAppVrHelp(application);
+ msg_params[hmi_request::menu_title] = "";
+
+ smart_objects::SmartObject key_board_properties =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ key_board_properties[strings::language] =
+ static_cast<int32_t>(hmi_apis::Common_Language::EN_US);
+ key_board_properties[hmi_request::keyboard_layout] =
+ static_cast<int32_t>(hmi_apis::Common_KeyboardLayout::QWERTY);
+
+ key_board_properties[hmi_request::auto_complete_text] = "";
+ msg_params[hmi_request::keyboard_properties] = key_board_properties;
+
+ msg_params[strings::app_id] = application->app_id();
+
+ SmartObjectSPtr message = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
+ DCHECK(message);
+
+ SmartObject& object = *message;
+ object[strings::params][strings::function_id] =
+ hmi_apis::FunctionID::UI_SetGlobalProperties;
+
+ object[strings::msg_params] = msg_params;
+
+ app_mngr.ManageHMICommand(message);
+ }
+
+ {
+ SmartObject msg_params = SmartObject(smart_objects::SmartType_Map);
+
+ msg_params[strings::help_prompt] = application->help_prompt();
+ msg_params[strings::timeout_prompt] = application->timeout_prompt();
+ msg_params[strings::app_id] = application->app_id();
+
+ SmartObjectSPtr message = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
+ DCHECK(message);
+
+ SmartObject& object = *message;
+ object[strings::params][strings::function_id] =
+ hmi_apis::FunctionID::TTS_SetGlobalProperties;
+
+ object[strings::msg_params] = msg_params;
+
+ app_mngr.ManageHMICommand(message);
+ }
+}
+
+void MessageHelper::SendUnsubscribeButtonNotification(
+ mobile_apis::ButtonName::eType button,
+ ApplicationSharedPtr application,
+ ApplicationManager& app_mngr) {
+ using namespace smart_objects;
+ using namespace hmi_apis;
+
+ SmartObject msg_params = SmartObject(SmartType_Map);
+ msg_params[strings::app_id] = application->app_id();
+ msg_params[strings::name] = button;
+ msg_params[strings::is_suscribed] = false;
+
+ SmartObjectSPtr message = CreateMessageForHMI(
+ hmi_apis::messageType::notification, app_mngr.GetNextHMICorrelationID());
+ DCHECK(message);
+
+ SmartObject& object = *message;
+ object[strings::params][strings::function_id] =
+ hmi_apis::FunctionID::Buttons_OnButtonSubscription;
+
+ object[strings::msg_params] = msg_params;
+
+ app_mngr.ManageHMICommand(message);
+}
+
+void MessageHelper::SendUnsubscribeIVIRequest(int32_t ivi_id,
+ ApplicationSharedPtr application,
+ ApplicationManager& app_mngr) {
+ using namespace smart_objects;
+
+ std::string key_name;
+ for (auto item : vehicle_data_) {
+ if (ivi_id == item.second) {
+ key_name = item.first;
+ break;
+ }
+ }
+
+ if (key_name.empty()) {
+ return;
+ }
+
+ smart_objects::SmartObject msg_params =
+ smart_objects::SmartObject(smart_objects::SmartType_Map);
+ msg_params[key_name] = true;
+
+ SmartObjectSPtr message = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
+ DCHECK(message);
+
+ SmartObject& object = *message;
+ object[strings::params][strings::function_id] =
+ hmi_apis::FunctionID::VehicleInfo_UnsubscribeVehicleData;
+
+ object[strings::msg_params] = msg_params;
+
+ app_mngr.ManageHMICommand(message);
+}
+
const VehicleData& MessageHelper::vehicle_data() {
return vehicle_data_;
}
@@ -873,7 +1120,7 @@ smart_objects::SmartObjectList MessageHelper::GetIVISubscriptionRequests(
if (true == msg_params.keyExists(sr.str) &&
true == msg_params[sr.str].asBool()) {
smart_objects::SmartObjectSPtr request =
- MessageHelper::CreateModuleInfoSO(sr.func_id);
+ MessageHelper::CreateModuleInfoSO(sr.func_id, app_mngr);
(*request)[strings::msg_params] = msg_params;
hmi_requests.push_back(request);
}
@@ -950,7 +1197,9 @@ void MessageHelper::SendSetAppIcon(
using namespace smart_objects;
SmartObjectSPtr set_app_icon =
- CreateRequestObject(application_manager.GetNextHMICorrelationID());
+ CreateMessageForHMI(hmi_apis::messageType::request,
+ application_manager.GetNextHMICorrelationID());
+
if (set_app_icon) {
SmartObject& so_to_send = *set_app_icon;
so_to_send[strings::params][strings::function_id] =
@@ -1009,7 +1258,7 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI(
if (app->vr_help_title() || app->vr_help()) {
smart_objects::SmartObjectSPtr ui_global_properties =
- CreateRequestObject(correlation_id);
+ CreateMessageForHMI(hmi_apis::messageType::request, correlation_id);
if (!ui_global_properties) {
return requests;
}
@@ -1044,7 +1293,7 @@ MessageHelper::CreateGlobalPropertiesRequestsToHMI(
// TTS global properties
if (app->help_prompt() || app->timeout_prompt()) {
smart_objects::SmartObjectSPtr tts_global_properties =
- CreateRequestObject(correlation_id);
+ CreateMessageForHMI(hmi_apis::messageType::request, correlation_id);
if (!tts_global_properties) {
return requests;
}
@@ -1076,8 +1325,9 @@ void MessageHelper::SendTTSGlobalProperties(ApplicationSharedPtr app,
if (!app) {
return;
}
- smart_objects::SmartObjectSPtr tts_global_properties =
- CreateRequestObject(app_man.GetNextHMICorrelationID());
+ smart_objects::SmartObjectSPtr tts_global_properties = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_man.GetNextHMICorrelationID());
+
if (tts_global_properties) {
smart_objects::SmartObject& so_to_send = *tts_global_properties;
so_to_send[strings::params][strings::function_id] =
@@ -1155,7 +1405,7 @@ smart_objects::SmartObjectList MessageHelper::CreateShowRequestToHMI(
if (app->show_command()) {
smart_objects::SmartObjectSPtr ui_show =
- CreateRequestObject(correlation_id);
+ CreateMessageForHMI(hmi_apis::messageType::request, correlation_id);
(*ui_show)[strings::params][strings::function_id] =
static_cast<int>(hmi_apis::FunctionID::UI_Show);
@@ -1187,8 +1437,8 @@ void MessageHelper::SendShowConstantTBTRequestToHMI(
}
if (app->tbt_show_command()) {
- smart_objects::SmartObjectSPtr navi_show_tbt =
- CreateRequestObject(app_man.GetNextHMICorrelationID());
+ smart_objects::SmartObjectSPtr navi_show_tbt = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_man.GetNextHMICorrelationID());
if (!navi_show_tbt) {
return;
}
@@ -1228,8 +1478,8 @@ smart_objects::SmartObjectList MessageHelper::CreateAddCommandRequestToHMI(
for (; commands.end() != i; ++i) {
// UI Interface
if ((*i->second).keyExists(strings::menu_params)) {
- smart_objects::SmartObjectSPtr ui_command =
- CreateRequestObject(app_mngr.GetNextHMICorrelationID());
+ smart_objects::SmartObjectSPtr ui_command = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
if (!ui_command) {
return requests;
}
@@ -1281,8 +1531,8 @@ MessageHelper::CreateAddVRCommandRequestFromChoiceToHMI(
(*(it->second))[strings::grammar_id].asUInt();
const size_t size = (*(it->second))[strings::choice_set].length();
for (size_t j = 0; j < size; ++j) {
- smart_objects::SmartObjectSPtr vr_command =
- CreateRequestObject(app_mngr.GetNextHMICorrelationID());
+ smart_objects::SmartObjectSPtr vr_command = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
if (!vr_command) {
return requests;
}
@@ -1315,8 +1565,8 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateChangeRegistration(
const uint32_t app_id,
const smart_objects::SmartObject* app_types,
ApplicationManager& app_mngr) {
- smart_objects::SmartObjectSPtr command =
- CreateRequestObject(app_mngr.GetNextHMICorrelationID());
+ smart_objects::SmartObjectSPtr command = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
if (!command) {
return NULL;
}
@@ -1372,8 +1622,8 @@ smart_objects::SmartObjectSPtr MessageHelper::CreateAddVRCommandToHMI(
const smart_objects::SmartObject& vr_commands,
uint32_t app_id,
ApplicationManager& app_mngr) {
- smart_objects::SmartObjectSPtr vr_command =
- CreateRequestObject(app_mngr.GetNextHMICorrelationID());
+ smart_objects::SmartObjectSPtr vr_command = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
if (!vr_command) {
return NULL;
}
@@ -1492,7 +1742,7 @@ smart_objects::SmartObjectList MessageHelper::CreateAddSubMenuRequestToHMI(
SubMenuMap::const_iterator i = sub_menu.begin();
for (; sub_menu.end() != i; ++i) {
smart_objects::SmartObjectSPtr ui_sub_menu =
- CreateRequestObject(correlation_id);
+ CreateMessageForHMI(hmi_apis::messageType::request, correlation_id);
if (!ui_sub_menu) {
return requsets;
}
@@ -1531,7 +1781,7 @@ void MessageHelper::SendOnAppUnregNotificationToHMI(
message[strings::params][strings::message_type] = MessageType::kNotification;
// we put hmi_app_id because applicaton list does not contain application on
// this momment
- // and ReplaceHMIByMobileAppId function will be unable to replace app_id to
+ // and ReplaceHMIWithMobileAppId function will be unable to replace app_id to
// hmi_app_id
message[strings::msg_params][strings::app_id] = app->hmi_app_id();
message[strings::msg_params][strings::unexpected_disconnect] =
@@ -1681,8 +1931,8 @@ void MessageHelper::SendPolicyUpdate(const std::string& file_path,
const uint32_t timeout,
const std::vector<int>& retries,
ApplicationManager& app_mngr) {
- smart_objects::SmartObjectSPtr message =
- CreateRequestObject(app_mngr.GetNextHMICorrelationID());
+ smart_objects::SmartObjectSPtr message = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
smart_objects::SmartObject& object = *message;
object[strings::params][strings::function_id] =
hmi_apis::FunctionID::BasicCommunication_PolicyUpdate;
@@ -1863,8 +2113,8 @@ void MessageHelper::SendNaviSetVideoConfig(
ApplicationManager& app_mngr,
const smart_objects::SmartObject& video_params) {
LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObjectSPtr request =
- CreateRequestObject(app_mngr.GetNextHMICorrelationID());
+ smart_objects::SmartObjectSPtr request = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
if (!request) {
return;
}
@@ -1881,8 +2131,8 @@ void MessageHelper::SendNaviSetVideoConfig(
void MessageHelper::SendNaviStartStream(const int32_t app_id,
ApplicationManager& app_mngr) {
LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObjectSPtr start_stream =
- CreateRequestObject(app_mngr.GetNextHMICorrelationID());
+ smart_objects::SmartObjectSPtr start_stream = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
if (!start_stream) {
return;
}
@@ -1920,8 +2170,8 @@ void MessageHelper::SendNaviStartStream(const int32_t app_id,
void MessageHelper::SendNaviStopStream(const int32_t app_id,
ApplicationManager& app_mngr) {
LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObjectSPtr stop_stream =
- CreateRequestObject(app_mngr.GetNextHMICorrelationID());
+ smart_objects::SmartObjectSPtr stop_stream = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
if (!stop_stream) {
return;
}
@@ -1937,8 +2187,8 @@ void MessageHelper::SendNaviStopStream(const int32_t app_id,
void MessageHelper::SendAudioStartStream(const int32_t app_id,
ApplicationManager& app_mngr) {
LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObjectSPtr start_stream =
- CreateRequestObject(app_mngr.GetNextHMICorrelationID());
+ smart_objects::SmartObjectSPtr start_stream = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
if (!start_stream) {
return;
@@ -1977,8 +2227,8 @@ void MessageHelper::SendAudioStartStream(const int32_t app_id,
void MessageHelper::SendAudioStopStream(const int32_t app_id,
ApplicationManager& app_mngr) {
LOG4CXX_AUTO_TRACE(logger_);
- smart_objects::SmartObjectSPtr stop_stream =
- CreateRequestObject(app_mngr.GetNextHMICorrelationID());
+ smart_objects::SmartObjectSPtr stop_stream = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
if (!stop_stream) {
return;
@@ -2027,8 +2277,8 @@ void MessageHelper::SendOnDataStreaming(
bool MessageHelper::SendStopAudioPathThru(ApplicationManager& app_mngr) {
LOG4CXX_INFO(logger_, "MessageHelper::SendAudioStopAudioPathThru");
- smart_objects::SmartObjectSPtr result =
- CreateRequestObject(app_mngr.GetNextHMICorrelationID());
+ smart_objects::SmartObjectSPtr result = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
(*result)[strings::params][strings::function_id] =
hmi_apis::FunctionID::UI_EndAudioPassThru;
@@ -2039,8 +2289,8 @@ bool MessageHelper::SendStopAudioPathThru(ApplicationManager& app_mngr) {
bool MessageHelper::SendUnsubscribedWayPoints(ApplicationManager& app_mngr) {
LOG4CXX_INFO(logger_, "MessageHelper::SendUnsubscribedWayPoints");
- smart_objects::SmartObjectSPtr result =
- CreateRequestObject(app_mngr.GetNextHMICorrelationID());
+ smart_objects::SmartObjectSPtr result = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
(*result)[strings::params][strings::function_id] =
hmi_apis::FunctionID::Navigation_UnsubscribeWayPoints;
@@ -2399,8 +2649,8 @@ void MessageHelper::SendOnStatusUpdate(const std::string& status,
}
void MessageHelper::SendGetSystemInfoRequest(ApplicationManager& app_mngr) {
- smart_objects::SmartObjectSPtr message =
- CreateRequestObject(app_mngr.GetNextHMICorrelationID());
+ smart_objects::SmartObjectSPtr message = CreateMessageForHMI(
+ hmi_apis::messageType::request, app_mngr.GetNextHMICorrelationID());
if (!message) {
return;
}
diff --git a/src/components/application_manager/src/mobile_message_handler.cc b/src/components/application_manager/src/mobile_message_handler.cc
index bc3aa32731..2f06c5f3b5 100644
--- a/src/components/application_manager/src/mobile_message_handler.cc
+++ b/src/components/application_manager/src/mobile_message_handler.cc
@@ -196,9 +196,8 @@ MobileMessageHandler::HandleIncomingMessageProtocolV2(
outgoing_message->set_payload_size(message->payload_size());
if (!payload.data.empty()) {
- BinaryData binary_payload_data(payload.data);
+ const BinaryData binary_payload_data(payload.data);
outgoing_message->set_binary_data(&binary_payload_data);
- outgoing_message->set_binary_data(&payload.data);
}
return outgoing_message.release();
}
diff --git a/src/components/application_manager/src/policies/policy_handler.cc b/src/components/application_manager/src/policies/policy_handler.cc
index e6ebaf3b83..b6b208b39b 100644
--- a/src/components/application_manager/src/policies/policy_handler.cc
+++ b/src/components/application_manager/src/policies/policy_handler.cc
@@ -852,6 +852,13 @@ uint32_t PolicyHandler::ChooseRandomAppForPolicyUpdate(
return 0;
}
+void PolicyHandler::OnDeviceSwitching(const std::string& device_id_from,
+ const std::string& device_id_to) {
+ LOG4CXX_AUTO_TRACE(logger_);
+ POLICY_LIB_CHECK_VOID();
+ policy_manager_->OnDeviceSwitching(device_id_from, device_id_to);
+}
+
void PolicyHandler::OnGetStatusUpdate(const uint32_t correlation_id) {
LOG4CXX_AUTO_TRACE(logger_);
POLICY_LIB_CHECK_VOID();
@@ -1170,7 +1177,7 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification(
continue;
}
policy_manager_->SetUserConsentForDevice(device_id, is_allowed);
- uint32_t device_handle = 0;
+ connection_handler::DeviceHandle device_handle = 0;
if (!connection_handler.GetDeviceID(device_id, &device_handle)) {
LOG4CXX_WARN(logger_,
"Device handle with mac " << device_id
@@ -1204,7 +1211,7 @@ void PolicyHandler::OnAllowSDLFunctionalityNotification(
}
// Case, when specific device was changed
- uint32_t device_handle = 0u;
+ connection_handler::DeviceHandle device_handle = 0u;
if (device_specific) {
policy_manager_->SetUserConsentForDevice(device_mac, is_allowed);
if (!connection_handler.GetDeviceID(device_mac, &device_handle)) {
@@ -1768,7 +1775,7 @@ void PolicyHandler::OnCertificateUpdated(const std::string& certificate_data) {
void PolicyHandler::OnPTUFinished(const bool ptu_result) {
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock lock(listeners_lock_);
- HandlersCollection::const_iterator it = listeners_.begin();
+
std::for_each(
listeners_.begin(),
listeners_.end(),
diff --git a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
index c8740227df..72f2246e7c 100644
--- a/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
+++ b/src/components/application_manager/src/resumption/resume_ctrl_impl.cc
@@ -67,6 +67,7 @@ ResumeCtrlImpl::ResumeCtrlImpl(ApplicationManager& application_manager)
this, &ResumeCtrlImpl::SaveDataOnTimer))
, is_resumption_active_(false)
, is_data_saved_(false)
+ , is_suspended_(false)
, launch_time_(time(NULL))
, application_manager_(application_manager) {}
#ifdef BUILD_TESTS
@@ -263,16 +264,25 @@ bool ResumeCtrlImpl::RemoveApplicationFromSaved(
void ResumeCtrlImpl::OnSuspend() {
LOG4CXX_AUTO_TRACE(logger_);
- StopSavePersistentDataTimer();
- SaveAllApplications();
- resumption_storage_->OnSuspend();
- resumption_storage_->Persist();
+ is_suspended_ = true;
+ FinalPersistData();
+}
+
+void ResumeCtrlImpl::OnIgnitionOff() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ resumption_storage_->IncrementIgnOffCount();
+ FinalPersistData();
}
void ResumeCtrlImpl::OnAwake() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ is_suspended_ = false;
ResetLaunchTime();
StartSavePersistentDataTimer();
- return resumption_storage_->OnAwake();
+}
+
+bool ResumeCtrlImpl::is_suspended() const {
+ return is_suspended_;
}
void ResumeCtrlImpl::StartSavePersistentDataTimer() {
@@ -433,6 +443,13 @@ void ResumeCtrlImpl::SaveDataOnTimer() {
}
}
+void ResumeCtrlImpl::FinalPersistData() {
+ LOG4CXX_AUTO_TRACE(logger_);
+ StopSavePersistentDataTimer();
+ SaveAllApplications();
+ resumption_storage_->Persist();
+}
+
bool ResumeCtrlImpl::IsDeviceMacAddressEqual(
ApplicationSharedPtr application, const std::string& saved_device_mac) {
LOG4CXX_AUTO_TRACE(logger_);
@@ -580,7 +597,7 @@ void ResumeCtrlImpl::AddWayPointsSubscription(
const smart_objects::SmartObject& subscribed_for_way_points_so =
saved_app[strings::subscribed_for_way_points];
if (true == subscribed_for_way_points_so.asBool()) {
- application_manager_.SubscribeAppForWayPoints(application->app_id());
+ application_manager_.SubscribeAppForWayPoints(application);
}
}
}
@@ -774,7 +791,7 @@ void ResumeCtrlImpl::LoadResumeData() {
"Resumption data for application "
<< app_id << " and device id " << device_id
<< " will be dropped.");
- resumption_storage_->DropAppDataResumption(device_id, app_id);
+ resumption_storage_->RemoveApplicationFromSaved(app_id, device_id);
continue;
}
}
diff --git a/src/components/application_manager/src/resumption/resumption_data_db.cc b/src/components/application_manager/src/resumption/resumption_data_db.cc
index 08de6d8190..b031fd0afd 100644
--- a/src/components/application_manager/src/resumption/resumption_data_db.cc
+++ b/src/components/application_manager/src/resumption/resumption_data_db.cc
@@ -212,7 +212,9 @@ uint32_t ResumptionDataDB::GetHMIApplicationID(
return hmi_app_id;
}
-void ResumptionDataDB::OnSuspend() {
+DEPRECATED void ResumptionDataDB::OnSuspend() {}
+
+void ResumptionDataDB::IncrementIgnOffCount() {
LOG4CXX_AUTO_TRACE(logger_);
utils::dbms::SQLQuery query_update_suspend_data(db());
@@ -291,7 +293,9 @@ bool ResumptionDataDB::GetHashId(const std::string& policy_app_id,
return SelectHashId(policy_app_id, device_id, hash_id);
}
-void ResumptionDataDB::OnAwake() {
+DEPRECATED void ResumptionDataDB::OnAwake() {}
+
+void ResumptionDataDB::DecrementIgnOffCount() {
LOG4CXX_AUTO_TRACE(logger_);
UpdateDataOnAwake();
@@ -2578,7 +2582,7 @@ bool ResumptionDataDB::InsertApplicationData(
const mobile_apis::HMILevel::eType hmi_level = application.m_hmi_level;
bool is_media_application = application.m_is_media_application;
bool is_subscribed_for_way_points =
- application_manager_.IsAppSubscribedForWayPoints(connection_key);
+ application_manager_.IsAppSubscribedForWayPoints(application.app_ptr);
if (!query.Prepare(kInsertApplication)) {
LOG4CXX_WARN(logger_,
@@ -2804,6 +2808,7 @@ ApplicationParams::ApplicationParams(app_mngr::ApplicationSharedPtr application)
m_hmi_app_id = application->hmi_app_id();
m_hmi_level = application->hmi_level();
m_is_media_application = application->IsAudioApplication();
+ app_ptr = application;
}
}
diff --git a/src/components/application_manager/src/resumption/resumption_data_json.cc b/src/components/application_manager/src/resumption/resumption_data_json.cc
index 7866fc4de1..e99d8bae26 100644
--- a/src/components/application_manager/src/resumption/resumption_data_json.cc
+++ b/src/components/application_manager/src/resumption/resumption_data_json.cc
@@ -66,7 +66,7 @@ void ResumptionDataJson::SaveApplication(
const std::string device_mac = application->mac_address();
const mobile_apis::HMILevel::eType hmi_level = application->hmi_level();
const bool is_subscribed_for_way_points =
- application_manager_.IsAppSubscribedForWayPoints(application->app_id());
+ application_manager_.IsAppSubscribedForWayPoints(application);
sync_primitives::AutoLock autolock(resumption_lock_);
Json::Value tmp;
@@ -143,11 +143,13 @@ uint32_t ResumptionDataJson::GetHMIApplicationID(
return hmi_app_id;
}
-void ResumptionDataJson::OnSuspend() {
+DEPRECATED void ResumptionDataJson::OnSuspend() {}
+
+void ResumptionDataJson::IncrementIgnOffCount() {
using namespace app_mngr;
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock autolock(resumption_lock_);
- Json::Value to_save;
+ Json::Value to_save = Json::arrayValue;
for (Json::Value::iterator it = GetSavedApplications().begin();
it != GetSavedApplications().end();
++it) {
@@ -167,7 +169,9 @@ void ResumptionDataJson::OnSuspend() {
LOG4CXX_DEBUG(logger_, GetResumptionData().toStyledString());
}
-void ResumptionDataJson::OnAwake() {
+DEPRECATED void ResumptionDataJson::OnAwake() {}
+
+void ResumptionDataJson::DecrementIgnOffCount() {
using namespace app_mngr;
LOG4CXX_AUTO_TRACE(logger_);
sync_primitives::AutoLock autolock(resumption_lock_);
diff --git a/src/components/application_manager/src/state_controller_impl.cc b/src/components/application_manager/src/state_controller_impl.cc
index b456ff6abb..84081a3830 100644
--- a/src/components/application_manager/src/state_controller_impl.cc
+++ b/src/components/application_manager/src/state_controller_impl.cc
@@ -123,7 +123,7 @@ void StateControllerImpl::SetRegularState(
HmiStatePtr prev_regular = app->RegularHmiState();
DCHECK_OR_RETURN_VOID(prev_regular);
HmiStatePtr hmi_state =
- CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
+ CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR);
DCHECK_OR_RETURN_VOID(hmi_state);
hmi_state->set_hmi_level(hmi_level);
hmi_state->set_audio_streaming_state(audio_state);
@@ -144,7 +144,7 @@ void StateControllerImpl::SetRegularState(
return;
}
const HmiStatePtr hmi_state =
- CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
+ CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR);
DCHECK_OR_RETURN_VOID(hmi_state);
hmi_state->set_hmi_level(hmi_level);
@@ -166,7 +166,7 @@ void StateControllerImpl::SetRegularState(
return;
}
HmiStatePtr hmi_state =
- CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
+ CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR);
DCHECK_OR_RETURN_VOID(hmi_state);
hmi_state->set_hmi_level(hmi_level);
hmi_state->set_audio_streaming_state(audio_state);
@@ -184,7 +184,7 @@ void StateControllerImpl::SetRegularState(
}
HmiStatePtr prev_state = app->RegularHmiState();
HmiStatePtr hmi_state =
- CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
+ CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR);
DCHECK_OR_RETURN_VOID(hmi_state);
hmi_state->set_hmi_level(hmi_level);
hmi_state->set_audio_streaming_state(CalcAudioState(app, hmi_level));
@@ -206,7 +206,7 @@ void StateControllerImpl::SetRegularState(
HmiStatePtr prev_regular = app->RegularHmiState();
DCHECK_OR_RETURN_VOID(prev_regular);
HmiStatePtr hmi_state =
- CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
+ CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR);
DCHECK_OR_RETURN_VOID(hmi_state);
hmi_state->set_hmi_level(prev_regular->hmi_level());
hmi_state->set_audio_streaming_state(
@@ -227,7 +227,7 @@ void StateControllerImpl::SetRegularState(
HmiStatePtr prev_state = app->RegularHmiState();
DCHECK_OR_RETURN_VOID(prev_state);
HmiStatePtr hmi_state =
- CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
+ CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR);
DCHECK_OR_RETURN_VOID(hmi_state);
hmi_state->set_hmi_level(prev_state->hmi_level());
hmi_state->set_audio_streaming_state(audio_state);
@@ -325,7 +325,7 @@ HmiStatePtr StateControllerImpl::ResolveHmiState(ApplicationSharedPtr app,
<< state->system_context());
HmiStatePtr available_state =
- CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
+ CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR);
DCHECK_OR_RETURN(available_state, HmiStatePtr());
available_state->set_hmi_level(state->hmi_level());
available_state->set_audio_streaming_state(state->audio_streaming_state());
@@ -502,7 +502,7 @@ void StateControllerImpl::SetupRegularHmiState(ApplicationSharedPtr app,
<< ", system_context " << state->system_context());
HmiStatePtr curr_state = app->CurrentHmiState();
HmiStatePtr old_state =
- CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
+ CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR);
DCHECK_OR_RETURN_VOID(old_state);
old_state->set_hmi_level(curr_state->hmi_level());
old_state->set_audio_streaming_state(curr_state->audio_streaming_state());
@@ -533,7 +533,7 @@ void StateControllerImpl::SetupRegularHmiState(
HmiStatePtr prev_state = app->RegularHmiState();
DCHECK_OR_RETURN_VOID(prev_state);
HmiStatePtr new_state =
- CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
+ CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR);
DCHECK_OR_RETURN_VOID(new_state);
new_state->set_hmi_level(hmi_level);
new_state->set_audio_streaming_state(audio_state);
@@ -716,7 +716,7 @@ void StateControllerImpl::OnApplicationRegistered(
active_states_lock_.Acquire();
StateIDList::iterator it = active_states_.begin();
for (; it != active_states_.end(); ++it) {
- HmiStatePtr new_state = CreateHmiState(app->app_id(), *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();
@@ -726,7 +726,7 @@ void StateControllerImpl::OnApplicationRegistered(
active_states_lock_.Release();
HmiStatePtr default_state =
- CreateHmiState(app->app_id(), HmiState::StateID::STATE_ID_REGULAR);
+ CreateHmiState(app, HmiState::StateID::STATE_ID_REGULAR);
DCHECK_OR_RETURN_VOID(default_state);
default_state->set_hmi_level(default_level);
default_state->set_audio_streaming_state(CalcAudioState(app, default_level));
@@ -896,49 +896,49 @@ bool StateControllerImpl::IsStateActive(HmiState::StateID state_id) const {
}
HmiStatePtr StateControllerImpl::CreateHmiState(
- uint32_t app_id, HmiState::StateID state_id) const {
+ utils::SharedPtr<Application> app, HmiState::StateID state_id) const {
using namespace utils;
LOG4CXX_AUTO_TRACE(logger_);
HmiStatePtr new_state;
switch (state_id) {
case HmiState::STATE_ID_PHONE_CALL: {
- new_state = MakeShared<PhoneCallHmiState>(app_id, app_mngr_);
+ new_state = MakeShared<PhoneCallHmiState>(app, app_mngr_);
break;
}
case HmiState::STATE_ID_SAFETY_MODE: {
- new_state = MakeShared<SafetyModeHmiState>(app_id, app_mngr_);
+ new_state = MakeShared<SafetyModeHmiState>(app, app_mngr_);
break;
}
case HmiState::STATE_ID_VR_SESSION: {
- new_state = MakeShared<VRHmiState>(app_id, app_mngr_);
+ new_state = MakeShared<VRHmiState>(app, app_mngr_);
break;
}
case HmiState::STATE_ID_TTS_SESSION: {
- new_state = MakeShared<TTSHmiState>(app_id, app_mngr_);
+ new_state = MakeShared<TTSHmiState>(app, app_mngr_);
break;
}
case HmiState::STATE_ID_NAVI_STREAMING: {
- new_state = MakeShared<NaviStreamingHmiState>(app_id, app_mngr_);
+ new_state = MakeShared<NaviStreamingHmiState>(app, app_mngr_);
break;
}
case HmiState::STATE_ID_REGULAR: {
- new_state = MakeShared<HmiState>(app_id, app_mngr_);
+ new_state = MakeShared<HmiState>(app, app_mngr_);
break;
}
case HmiState::STATE_ID_POSTPONED: {
- new_state = MakeShared<HmiState>(app_id, app_mngr_, state_id);
+ new_state = MakeShared<HmiState>(app, app_mngr_, state_id);
break;
}
case HmiState::STATE_ID_DEACTIVATE_HMI: {
- new_state = MakeShared<DeactivateHMI>(app_id, app_mngr_);
+ new_state = MakeShared<DeactivateHMI>(app, app_mngr_);
break;
}
case HmiState::STATE_ID_AUDIO_SOURCE: {
- new_state = MakeShared<AudioSource>(app_id, app_mngr_);
+ new_state = MakeShared<AudioSource>(app, app_mngr_);
break;
}
case HmiState::STATE_ID_EMBEDDED_NAVI: {
- new_state = MakeShared<EmbeddedNavi>(app_id, app_mngr_);
+ new_state = MakeShared<EmbeddedNavi>(app, app_mngr_);
break;
}
default: