summaryrefslogtreecommitdiff
path: root/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc')
-rw-r--r--src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc222
1 files changed, 160 insertions, 62 deletions
diff --git a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
index 597df26d0a..b39e50b222 100644
--- a/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
+++ b/src/components/application_manager/rpc_plugins/sdl_rpc_plugin/src/commands/mobile/register_app_interface_request.cc
@@ -158,13 +158,14 @@ class SmartArrayValueExtractor {
};
struct IsSameNickname {
- IsSameNickname(const custom_str::CustomString& app_id) : app_id_(app_id) {}
+ IsSameNickname(const custom_str::CustomString app_name)
+ : app_name_(app_name) {}
bool operator()(const policy::StringArray::value_type& nickname) const {
- return app_id_.CompareIgnoreCase(nickname.c_str());
+ return app_name_.CompareIgnoreCase(nickname.c_str());
}
private:
- const custom_str::CustomString& app_id_;
+ const custom_str::CustomString app_name_;
};
} // namespace
@@ -184,13 +185,14 @@ RegisterAppInterfaceRequest::RegisterAppInterfaceRequest(
rpc_service,
hmi_capabilities,
policy_handler)
- , result_code_(mobile_apis::Result::INVALID_ENUM) {}
+ , result_code_(mobile_apis::Result::INVALID_ENUM)
+ , device_handle_(0) {}
RegisterAppInterfaceRequest::~RegisterAppInterfaceRequest() {}
bool RegisterAppInterfaceRequest::Init() {
LOG4CXX_AUTO_TRACE(logger_);
- return true;
+ return GetDataOnSessionKey(connection_key(), &device_handle_, &device_id_);
}
void RegisterAppInterfaceRequest::Run() {
@@ -224,20 +226,25 @@ void RegisterAppInterfaceRequest::Run() {
return;
}
+ LOG4CXX_DEBUG(
+ logger_,
+ "device_handle: " << device_handle_ << " device_id: " << device_id_);
+
if (IsApplicationSwitched()) {
return;
}
+ // Cache the original app ID (for legacy behavior)
+ const auto policy_app_id =
+ application_manager_.GetCorrectMobileIDFromMessage(message_);
+
ApplicationSharedPtr application =
- application_manager_.application(connection_key());
+ application_manager_.application(device_id_, policy_app_id);
if (application) {
SendResponse(false, mobile_apis::Result::APPLICATION_REGISTERED_ALREADY);
return;
}
- // cache the original app ID (for legacy behavior)
- const std::string policy_app_id =
- application_manager_.GetCorrectMobileIDFromMessage(message_);
const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
@@ -576,6 +583,13 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params,
}
if (hmi_capabilities.display_capabilities()->keyExists(
+ strings::menu_layouts_available)) {
+ display_caps[strings::menu_layouts_available] =
+ hmi_capabilities.display_capabilities()->getElement(
+ strings::menu_layouts_available);
+ }
+
+ if (hmi_capabilities.display_capabilities()->keyExists(
hmi_response::media_clock_formats)) {
display_caps[hmi_response::media_clock_formats] =
hmi_capabilities.display_capabilities()->getElement(
@@ -613,15 +627,9 @@ void FillUIRelatedFields(smart_objects::SmartObject& response_params,
}
if (hmi_capabilities.audio_pass_thru_capabilities()) {
- if (smart_objects::SmartType_Array ==
- hmi_capabilities.audio_pass_thru_capabilities()->getType()) {
- // hmi_capabilities json contains array and HMI response object
- response_params[strings::audio_pass_thru_capabilities] =
- *hmi_capabilities.audio_pass_thru_capabilities();
- } else {
- response_params[strings::audio_pass_thru_capabilities][0] =
- *hmi_capabilities.audio_pass_thru_capabilities();
- }
+ // hmi_capabilities json contains array and HMI response object
+ response_params[strings::audio_pass_thru_capabilities] =
+ *hmi_capabilities.audio_pass_thru_capabilities();
}
response_params[strings::hmi_capabilities] =
smart_objects::SmartObject(smart_objects::SmartType_Map);
@@ -821,6 +829,16 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
application->mac_address());
}
+ // If app is in resuming state
+ // DisplayCapabilitiesBuilder has to collect all the information
+ // from incoming HMI notifications and send only one notification
+ // to mobile app, even if hash does not match, which means that app data
+ // will not be resumed, notification should be sent for default window as
+ // it will be resumed in any case
+ if (resumption) {
+ resumer.StartWaitingForDisplayCapabilitiesUpdate(application);
+ }
+
AppHmiTypes hmi_types;
if ((*message_)[strings::msg_params].keyExists(strings::app_hmi_type)) {
smart_objects::SmartArray* hmi_types_ptr =
@@ -835,14 +853,15 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
}
}
policy::StatusNotifier notify_upd_manager = GetPolicyHandler().AddApplication(
- application->policy_app_id(), hmi_types);
+ application->mac_address(), application->policy_app_id(), hmi_types);
response_params[strings::icon_resumed] =
file_system::FileExists(application->app_icon_path());
SendResponse(true, result_code, add_info.c_str(), &response_params);
if (msg_params.keyExists(strings::app_hmi_type)) {
- GetPolicyHandler().SetDefaultHmiTypes(application->policy_app_id(),
+ GetPolicyHandler().SetDefaultHmiTypes(application->device(),
+ application->policy_app_id(),
&(msg_params[strings::app_hmi_type]));
}
@@ -856,12 +875,14 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile(
// Start PTU after successfull registration
// Sends OnPermissionChange notification to mobile right after RAI response
// and HMI level set-up
- GetPolicyHandler().OnAppRegisteredOnMobile(application->policy_app_id());
-
- if (result_code != mobile_apis::Result::RESUME_FAILED) {
- resumer.StartResumption(application, hash_id);
- } else {
- resumer.StartResumptionOnlyHMILevel(application);
+ GetPolicyHandler().OnAppRegisteredOnMobile(application->mac_address(),
+ application->policy_app_id());
+ if (resumption) {
+ if (result_code != mobile_apis::Result::RESUME_FAILED) {
+ resumer.StartResumption(application, hash_id);
+ } else {
+ resumer.StartResumptionOnlyHMILevel(application);
+ }
}
// By default app subscribed to CUSTOM_BUTTON
@@ -961,48 +982,72 @@ mobile_apis::Result::eType RegisterAppInterfaceRequest::CheckCoincidence(
const smart_objects::SmartObject& msg_params =
(*message_)[strings::msg_params];
- ApplicationSet accessor = application_manager_.applications().GetData();
+ auto compare_tts_name = [](const smart_objects::SmartObject& obj_1,
+ const smart_objects::SmartObject& obj_2) {
+ return obj_1[application_manager::strings::text]
+ .asCustomString()
+ .CompareIgnoreCase(
+ obj_2[application_manager::strings::text].asCustomString());
+ };
- ApplicationSetConstIt it = accessor.begin();
- const custom_str::CustomString& app_name =
- msg_params[strings::app_name].asCustomString();
+ const auto& accessor = application_manager_.applications().GetData();
+ const auto& app_name = msg_params[strings::app_name].asCustomString();
- for (; accessor.end() != it; ++it) {
- // name check
- const custom_str::CustomString& cur_name = (*it)->name();
+ for (const auto& app : accessor) {
+ if (app->device() != device_handle_) {
+ continue;
+ }
+ // Name check
+ const auto& cur_name = app->name();
if (app_name.CompareIgnoreCase(cur_name)) {
LOG4CXX_ERROR(logger_, "Application name is known already.");
- out_duplicate_apps.push_back(*it);
+ out_duplicate_apps.push_back(app);
continue;
}
-
- const smart_objects::SmartObject* vr = (*it)->vr_synonyms();
- const std::vector<smart_objects::SmartObject>* curr_vr = NULL;
- if (NULL != vr) {
- curr_vr = vr->asArray();
+ const auto vr = app->vr_synonyms();
+ if (vr) {
+ const auto curr_vr = vr->asArray();
CoincidencePredicateVR v(app_name);
if (0 != std::count_if(curr_vr->begin(), curr_vr->end(), v)) {
LOG4CXX_ERROR(logger_, "Application name is known already.");
- out_duplicate_apps.push_back(*it);
+ out_duplicate_apps.push_back(app);
continue;
}
}
- // vr check
+ // VR check
if (msg_params.keyExists(strings::vr_synonyms)) {
- const std::vector<smart_objects::SmartObject>* new_vr =
- msg_params[strings::vr_synonyms].asArray();
+ const auto new_vr = msg_params[strings::vr_synonyms].asArray();
CoincidencePredicateVR v(cur_name);
if (0 != std::count_if(new_vr->begin(), new_vr->end(), v)) {
LOG4CXX_ERROR(logger_, "vr_synonyms duplicated with app_name .");
- out_duplicate_apps.push_back(*it);
+ out_duplicate_apps.push_back(app);
continue;
}
- } // end vr check
+ } // End vr check
+
+ // TTS check
+ if (msg_params.keyExists(strings::tts_name) && app->tts_name()) {
+ const auto tts_array = msg_params[strings::tts_name].asArray();
+ const auto tts_curr = app->tts_name()->asArray();
+ const auto& it_tts = std::find_first_of(tts_array->begin(),
+ tts_array->end(),
+ tts_curr->begin(),
+ tts_curr->end(),
+ compare_tts_name);
+ if (it_tts != tts_array->end()) {
+ LOG4CXX_ERROR(
+ logger_,
+ "TTS name: "
+ << (*it_tts)[strings::text].asCustomString().AsMBString()
+ << " is known already");
+ return mobile_apis::Result::DUPLICATE_NAME;
+ }
+ } // End tts check
- } // application for end
+ } // Application for end
if (!out_duplicate_apps.empty()) {
return mobile_apis::Result::DUPLICATE_NAME;
@@ -1131,14 +1176,19 @@ bool RegisterAppInterfaceRequest::IsApplicationWithSameAppIdRegistered() {
const custom_string::CustomString mobile_app_id(
application_manager_.GetCorrectMobileIDFromMessage(message_));
- const ApplicationSet& applications =
- application_manager_.applications().GetData();
-
- ApplicationSetConstIt it = applications.begin();
- ApplicationSetConstIt it_end = applications.end();
-
- for (; it != it_end; ++it) {
- if (mobile_app_id.CompareIgnoreCase((*it)->policy_app_id().c_str())) {
+ const auto& applications = application_manager_.applications().GetData();
+
+ for (const auto& app : applications) {
+ if (mobile_app_id.CompareIgnoreCase(app->policy_app_id().c_str())) {
+ if (app->device() != device_handle_) {
+ LOG4CXX_DEBUG(logger_,
+ "These policy_app_id equal, but applications have "
+ "different device id"
+ << " mobile_app_id: " << mobile_app_id.c_str()
+ << " device_handle: " << device_handle_
+ << " device_handle: " << app->device());
+ continue;
+ }
return true;
}
}
@@ -1308,13 +1358,12 @@ void RegisterAppInterfaceRequest::CheckResponseVehicleTypeParam(
void RegisterAppInterfaceRequest::SendSubscribeCustomButtonNotification() {
using namespace smart_objects;
- using namespace hmi_apis;
-
SmartObject msg_params = SmartObject(SmartType_Map);
msg_params[strings::app_id] = connection_key();
- msg_params[strings::name] = Common_ButtonName::CUSTOM_BUTTON;
+ msg_params[strings::name] = hmi_apis::Common_ButtonName::CUSTOM_BUTTON;
msg_params[strings::is_suscribed] = true;
- CreateHMINotification(FunctionID::Buttons_OnButtonSubscription, msg_params);
+ CreateHMINotification(hmi_apis::FunctionID::Buttons_OnButtonSubscription,
+ msg_params);
}
bool RegisterAppInterfaceRequest::IsApplicationSwitched() {
@@ -1323,7 +1372,7 @@ bool RegisterAppInterfaceRequest::IsApplicationSwitched() {
LOG4CXX_DEBUG(logger_, "Looking for application id " << policy_app_id);
- auto app = application_manager_.application_by_policy_id(policy_app_id);
+ auto app = application_manager_.application(device_id_, policy_app_id);
if (!app) {
LOG4CXX_DEBUG(
@@ -1334,12 +1383,13 @@ bool RegisterAppInterfaceRequest::IsApplicationSwitched() {
LOG4CXX_DEBUG(logger_,
"Application with policy id " << policy_app_id << " is found.");
- if (!application_manager_.IsAppInReconnectMode(policy_app_id)) {
+ if (!application_manager_.IsAppInReconnectMode(device_handle_,
+ 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;
+ return true;
}
LOG4CXX_DEBUG(logger_, "Application is found in reconnection list.");
@@ -1358,13 +1408,61 @@ bool RegisterAppInterfaceRequest::IsApplicationSwitched() {
application_manager_.ProcessReconnection(app, connection_key());
SendRegisterAppInterfaceResponseToMobile(app_type);
- application_manager_.SendHMIStatusNotification(app);
+ MessageHelper::SendHMIStatusNotification(
+ app,
+ mobile_apis::PredefinedWindows::DEFAULT_WINDOW,
+ application_manager_);
application_manager_.OnApplicationSwitched(app);
return true;
}
+bool RegisterAppInterfaceRequest::GetDataOnSessionKey(
+ const uint32_t key,
+ connection_handler::DeviceHandle* device_id,
+ std::string* mac_address) const {
+ LOG4CXX_AUTO_TRACE(logger_);
+
+ if ((nullptr == mac_address) && (nullptr == device_id)) {
+ LOG4CXX_ERROR(logger_,
+ "Can't get data on session key because device id and mac "
+ "address are empty.");
+ return false;
+ }
+
+ connection_handler::DeviceHandle device_handle = 0;
+ auto& connect_handler = application_manager_.connection_handler();
+
+ auto result = connect_handler.GetDataOnSessionKey(
+ connection_key(), nullptr, nullptr, &device_handle);
+
+ if (result) {
+ LOG4CXX_DEBUG(
+ logger_,
+ "Failed to get device info for connection key: " << connection_key());
+ return false;
+ }
+
+ if (mac_address) {
+ result = connect_handler.get_session_observer().GetDataOnDeviceID(
+ device_handle, nullptr, nullptr, mac_address, nullptr);
+ }
+
+ if (result) {
+ LOG4CXX_DEBUG(logger_,
+ "Failed get unique address info for connection key: "
+ << connection_key());
+ return false;
+ }
+
+ if (device_id) {
+ *device_id = device_handle;
+ }
+
+ return true;
+}
+
policy::PolicyHandlerInterface&
RegisterAppInterfaceRequest::GetPolicyHandler() {
return policy_handler_;