diff options
12 files changed, 52 insertions, 41 deletions
diff --git a/src/components/application_manager/include/application_manager/application_manager_impl.h b/src/components/application_manager/include/application_manager/application_manager_impl.h index 0046b4bf4..5c5e29e06 100644 --- a/src/components/application_manager/include/application_manager/application_manager_impl.h +++ b/src/components/application_manager/include/application_manager/application_manager_impl.h @@ -343,7 +343,7 @@ class ApplicationManagerImpl : public ApplicationManager, */ mobile_api::HMILevel::eType IsHmiLevelFullAllowed(ApplicationSharedPtr app); - void ConnectToDevice(uint32_t id); + void ConnectToDevice(const std::string& device_mac); void OnHMIStartedCooperation(); /* diff --git a/src/components/application_manager/src/application_manager_impl.cc b/src/components/application_manager/src/application_manager_impl.cc index fbe5228a1..f42feaca0 100644 --- a/src/components/application_manager/src/application_manager_impl.cc +++ b/src/components/application_manager/src/application_manager_impl.cc @@ -545,14 +545,20 @@ mobile_api::HMILevel::eType ApplicationManagerImpl::IsHmiLevelFullAllowed( return result; } -void ApplicationManagerImpl::ConnectToDevice(uint32_t id) { +void ApplicationManagerImpl::ConnectToDevice(const std::string& device_mac) { // TODO(VS): Call function from ConnectionHandler if (!connection_handler_) { LOG4CXX_WARN(logger_, "Connection handler is not set."); return; } - connection_handler_->ConnectToDevice(id); + connection_handler::DeviceHandle handle; + if (!connection_handler_->GetDeviceID(device_mac, &handle) ) { + LOG4CXX_ERROR(logger_, "Attempt to connect to invalid device with mac:" + << device_mac ); + return; + } + connection_handler_->ConnectToDevice(handle); } void ApplicationManagerImpl::OnHMIStartedCooperation() { diff --git a/src/components/application_manager/src/commands/hmi/on_device_chosen_notification.cc b/src/components/application_manager/src/commands/hmi/on_device_chosen_notification.cc index 5d73c7b80..441538bee 100644 --- a/src/components/application_manager/src/commands/hmi/on_device_chosen_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_device_chosen_notification.cc @@ -50,7 +50,7 @@ void OnDeviceChosenNotification::Run() { if ((*message_)[strings::msg_params].keyExists(strings::device_info)) { ApplicationManagerImpl::instance()->ConnectToDevice( (*message_)[strings::msg_params][strings::device_info][strings::id] - .asInt()); + .asString()); } } diff --git a/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc b/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc index fbb2bcfe9..b41eb6b86 100644 --- a/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc +++ b/src/components/application_manager/src/commands/hmi/on_device_state_changed_notification.cc @@ -95,8 +95,7 @@ void OnDeviceStateChangedNotification::Run() { .asString(); if (device_id.empty()) { if ((*message_)[strings::msg_params].keyExists("deviceId")) { - device_id = MessageHelper::GetDeviceMacAddressForHandle( - (*message_)[strings::msg_params]["deviceId"]["id"].asInt()); + device_id = (*message_)[strings::msg_params]["deviceId"]["id"].asString(); } } else { // Policy uses hashed MAC address as device_id 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 11c53f6bd..ac6971ac3 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 @@ -493,21 +493,26 @@ void RegisterAppInterfaceRequest::SendRegisterAppInterfaceResponseToMobile( } - // By default app subscribed to CUSTOM_BUTTON - // Need to send notification to HMI - SendSubscribeCustomButtonNotification(); - - MessageHelper::SendChangeRegistrationRequestToHMI(application); - - SendResponse(true, result, add_info.c_str(), &response_params); MessageHelper::SendOnAppRegisteredNotificationToHMI(*(application.get()), resumption, need_restore_vr); + + SendResponse(true, result, add_info.c_str(), &response_params); + + // Default HMI level should be set before any permissions validation, since it + // relies on HMI level. + resumer.SetupDefaultHMILevel(application); + if (result != mobile_apis::Result::RESUME_FAILED) { resumer.StartResumption(application, hash_id); } else { resumer.StartResumptionOnlyHMILevel(application); } + + // By default app subscribed to CUSTOM_BUTTON + // Need to send notification to HMI + SendSubscribeCustomButtonNotification(); + MessageHelper::SendChangeRegistrationRequestToHMI(application); } mobile_apis::Result::eType diff --git a/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc b/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc index 25de8d3ef..b31879585 100644 --- a/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc +++ b/src/components/application_manager/src/commands/mobile/register_app_interface_response.cc @@ -60,16 +60,14 @@ void RegisterAppInterfaceResponse::Run() { // Add registered application to the policy db right after response sent to // mobile to be able to check all other API according to app permissions - uint32_t connection_key = - (*message_)[strings::params][strings::connection_key].asUInt(); application_manager::ApplicationConstSharedPtr app = application_manager::ApplicationManagerImpl::instance()-> - application(connection_key); + application(connection_key()); if (app.valid()) { policy::PolicyHandler *policy_handler = policy::PolicyHandler::instance(); std::string mobile_app_id = app->mobile_app_id(); policy_handler->AddApplication(mobile_app_id); - SetHeartBeatTimeout(connection_key, mobile_app_id); + SetHeartBeatTimeout(connection_key(), mobile_app_id); } } diff --git a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc index 784fa1cbf..1c0948d07 100644 --- a/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc +++ b/src/components/application_manager/src/commands/mobile/set_global_properties_request.cc @@ -333,14 +333,14 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { if (!IsPendingResponseExist()) { bool result = ((hmi_apis::Common_Result::SUCCESS == ui_result_) - && (hmi_apis::Common_Result::SUCCESS == tts_result_ || - hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_)) - || ((hmi_apis::Common_Result::SUCCESS == ui_result_ || - hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_) - && (hmi_apis::Common_Result::INVALID_ENUM == tts_result_)) - || ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_ || - hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_) - && (hmi_apis::Common_Result::SUCCESS == tts_result_)); + && (hmi_apis::Common_Result::SUCCESS == tts_result_ || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == tts_result_)) + || ((hmi_apis::Common_Result::SUCCESS == ui_result_ || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_) + && (hmi_apis::Common_Result::INVALID_ENUM == tts_result_)) + || ((hmi_apis::Common_Result::INVALID_ENUM == ui_result_ || + hmi_apis::Common_Result::UNSUPPORTED_RESOURCE == ui_result_) + && (hmi_apis::Common_Result::SUCCESS == tts_result_)); mobile_apis::Result::eType result_code; const char* return_info = NULL; @@ -352,19 +352,20 @@ void SetGlobalPropertiesRequest::on_event(const event_engine::Event& event) { std::string("Unsupported phoneme type sent in a prompt").c_str(); } else { result_code = static_cast<mobile_apis::Result::eType>( - std::max(ui_result_, tts_result_)); + std::max(ui_result_, tts_result_)); } } else { result_code = static_cast<mobile_apis::Result::eType>( - std::max(ui_result_, tts_result_)); + std::max(ui_result_, tts_result_)); } + // TODO(AOleynik): APPLINK-15858 + ApplicationSharedPtr application = + ApplicationManagerImpl::instance()->application(connection_key()); SendResponse(result, result_code, return_info, &(message[strings::msg_params])); - ApplicationSharedPtr application = - ApplicationManagerImpl::instance()->application(connection_key()); if (!application) { LOG4CXX_DEBUG(logger_, "NULL pointer."); return; diff --git a/src/components/application_manager/src/message_helper.cc b/src/components/application_manager/src/message_helper.cc index 2fd6d9f74..11bd6afda 100644 --- a/src/components/application_manager/src/message_helper.cc +++ b/src/components/application_manager/src/message_helper.cc @@ -335,7 +335,7 @@ void MessageHelper::SendOnAppRegisteredNotificationToHMI( << application_impl.device()); } device_info[strings::name] = device_name; - device_info[strings::id] = application_impl.device(); + device_info[strings::id] = mac_address; const policy::DeviceConsent device_consent = policy::PolicyHandler::instance()->GetUserConsentForDevice(mac_address); @@ -1320,7 +1320,7 @@ bool MessageHelper::CreateHMIApplicationStruct(ApplicationConstSharedPtr app, output[strings::device_info] = smart_objects::SmartObject(smart_objects::SmartType_Map); output[strings::device_info][strings::name] = device_name; - output[strings::device_info][strings::id] = app->device(); + output[strings::device_info][strings::id] = mac_address; const policy::DeviceConsent device_consent = policy::PolicyHandler::instance()->GetUserConsentForDevice(mac_address); output[strings::device_info][strings::isSDLAllowed] = @@ -1537,7 +1537,7 @@ void MessageHelper::SendSDLActivateAppResponse(policy::AppPermissions& permissio (*message)[strings::msg_params]["device"]["name"] = permissions.deviceInfo .device_name; (*message)[strings::msg_params]["device"]["id"] = permissions.deviceInfo - .device_handle; + .device_mac_address; } (*message)[strings::msg_params]["isAppRevoked"] = permissions.appRevoked; @@ -1577,7 +1577,7 @@ void MessageHelper::SendOnSDLConsentNeeded( (*message)[strings::params][strings::message_type] = MessageType::kNotification; - (*message)[strings::msg_params]["device"]["id"] = device_info.device_handle; + (*message)[strings::msg_params]["device"]["id"] = device_info.device_mac_address; (*message)[strings::msg_params]["device"]["name"] = device_info.device_name; ApplicationManagerImpl::instance()->ManageHMICommand(message); diff --git a/src/components/application_manager/src/mobile_message_handler.cc b/src/components/application_manager/src/mobile_message_handler.cc index a1c838554..732faf8a5 100644 --- a/src/components/application_manager/src/mobile_message_handler.cc +++ b/src/components/application_manager/src/mobile_message_handler.cc @@ -231,8 +231,13 @@ MobileMessageHandler::HandleOutgoingMessageProtocolV2( dataForSending[offset++] = jsonSize; memcpy(dataForSending + offset, message->json_message().c_str(), jsonSize); - + + // Default the service type to RPC Service + uint8_t type = 0x07; + if (message->has_binary_data()) { + // Change the service type to Hybrid Service + type = 0x0F; const std::vector<uint8_t>& binaryData = *(message->binary_data()); uint8_t* currentPointer = dataForSending + offset + jsonSize; for (uint32_t i = 0; i < binarySize; ++i) { @@ -244,7 +249,8 @@ MobileMessageHandler::HandleOutgoingMessageProtocolV2( new protocol_handler::RawMessage(message->connection_key(), message->protocol_version(), dataForSending, - dataForSendingSize); + dataForSendingSize, + type); delete [] dataForSending; diff --git a/src/components/application_manager/src/resume_ctrl.cpp b/src/components/application_manager/src/resume_ctrl.cpp index 6dd46aa3d..19cad8013 100644 --- a/src/components/application_manager/src/resume_ctrl.cpp +++ b/src/components/application_manager/src/resume_ctrl.cpp @@ -451,8 +451,6 @@ bool ResumeCtrl::StartResumption(ApplicationSharedPtr application, return false; } - SetupDefaultHMILevel(application); - LOG4CXX_DEBUG(logger_, " Resume app_id = " << application->app_id() << " hmi_app_id = " << application->hmi_app_id() << " mobile_id = " << application->mobile_app_id() @@ -544,8 +542,6 @@ bool ResumeCtrl::StartResumptionOnlyHMILevel(ApplicationSharedPtr application) { return false; } - SetupDefaultHMILevel(application); - LOG4CXX_DEBUG(logger_, "ENTER app_id = " << application->app_id() << "mobile_id = " << application->mobile_app_id()); diff --git a/src/components/interfaces/HMI_API.xml b/src/components/interfaces/HMI_API.xml index 0aae26f30..0f00117b1 100644 --- a/src/components/interfaces/HMI_API.xml +++ b/src/components/interfaces/HMI_API.xml @@ -1302,7 +1302,7 @@ <param name="name" type="String" mandatory="true"> <description>The name of the device connected.</description> </param> - <param name="id" type="Integer" mandatory="true"> + <param name="id" type="String" mandatory="true"> <description>The ID of the device connected</description> </param> <param name="transportType" type="Common.TransportType" mandatory="false"> diff --git a/src/components/interfaces/QT_HMI_API.xml b/src/components/interfaces/QT_HMI_API.xml index 6db4ec838..eab9edb86 100644 --- a/src/components/interfaces/QT_HMI_API.xml +++ b/src/components/interfaces/QT_HMI_API.xml @@ -1114,7 +1114,7 @@ <param name="name" type="String" mandatory="true"> <description>The name of the device connected.</description> </param> - <param name="id" type="Integer" mandatory="true"> + <param name="id" type="String" mandatory="true"> <description>The ID of the device connected</description> </param> <param name="transportType" type="Common.TransportType" mandatory="false"> |